String interpolation

Ovid publiustemp-londonpm at
Mon Nov 20 16:40:29 GMT 2006

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

It's not new, but it should be used with caution.  If you put too much
logic in there, it can get very confusing when a string throws an



Buy the book --
Perl and CGI --

More information about the mailing list