String interpolation
Ovid
publiustemp-londonpm at yahoo.com
Mon Nov 20 16:40:29 GMT 2006
--- Daniel Barlow <dan at telent.net> 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
exception.
Cheers,
Ovid
--
Buy the book -- http://www.oreilly.com/catalog/perlhks/
Perl and CGI -- http://users.easystreet.com/ovid/cgi_course/
More information about the london.pm
mailing list