String interpolation
Daniel Barlow
dan at telent.net
Mon Nov 20 16:13:10 GMT 2006
Having noted the existence of Interpolation.pm, and even despite
having read http://savage.net.au/Perl/html/interpolation.html , I
remained convinced that there should be some way to embed the result
of arbitrary Perl evaluation into a double-quoted string. And indeed
I appear to have found it: as witness -
DB<2> x "2 plus 2 is @{[2+2]}"
0 '2 plus 2 is 4'
DB<3> x "hello, my name is @{[ucfirst getlogin()]}. Who are you?"
0 'hello, my name is Dan. Who are you?'
I can't remember having seen this before: is that because (a) it's new
(unlikely, I know), (b) it's a bad idea, or (c) I just don't pay
enough attention when reading other people's code?
-dan
More information about the london.pm
mailing list