String interpolation

Nik Clayton nik at ngo.org.uk
Mon Nov 20 16:58:01 GMT 2006


Daniel Barlow wrote:
> 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?

This is the 'babycart' operator (depending on who you listen to)

     http://beta.nntp.perl.org/group/perl.fwp/2006/07/msg3855.html

N


More information about the london.pm mailing list