Re: RFC 110 (v3) counting matches
[email protected] (Bart Lateur)
| Newsgroups | perl.perl6.language.regex |
|---|---|
| Organization | MediaMind |
| Message-ID | <[email protected]> |
On Tue, 29 Aug 2000 16:21:35 -0600, Tom Christiansen wrote:
>>p.s. Has anybody already suggested that we ought to have a nicer
>>solution to execute perl code inside a string, replacing "${\(...)}" and
>>"@{[...]}", which also won't ever win a beauty contest? Oops, wrong
>>mailing list.
>
>The first one doesn't work, and never did. You want
>@{[....]} and @{[scalar ....]} instead.
"Doesn't work"?
print "The sum of 1 + 2 is ${\(1+2)}.\n";
-->
The sum of 1 + 2 is 3.
I'm surprised your wouldn't have known this. The principle is the same:
"${...}" expects a scalar reference inside the block, and '\' provides
one. Of course, there shouldn't be a real multi-element list inside the
parens, but just one scalar. And often, the parens aren't needed.
--
Bart.