String interpolation

Nik Clayton nik at
Mon Nov 20 16:58:01 GMT 2006

Daniel Barlow wrote:
> Having noted the existence of, and even despite
> having read , 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)


More information about the mailing list