On Wed, Jan 30, 2002 at 04:46:28PM +0100, Joerg Ziefle wrote: > ---------- Original Message ---------------------------------- > From: [EMAIL PROTECTED] > Reply-To: [EMAIL PROTECTED] > Date: Wed, 30 Jan 2002 16:24:20 +0100 > > >On Wed, Jan 30, 2002 at 03:55:32PM +0100, Joerg Ziefle wrote: > >> perl -e 'print "Current time is: @{[scalar localtime]}\n"' > >> > >> Note the obvious difference to: > >> > >> perl -e 'print "Current time is: @{[localtime]}\n"' > > > > > >Eh, it's the "scalar" that makes the scalar evaluation in those > >examples. After all "@{[scalar localtime]}" gives the result > >of 'localtime' in scalar context, not list context as you suggest. > > Ok, got me :) > The example was not the best and would have better been something along > > perl -e 'print "1 + 3 = ${\(1+3)}\n"'
That would not be a very good example, and 1 + 3 is 4 in both scalar and list context. > BTW, can you think of a clunkier way to get the name of the current script as > > print "Call me $${\localtime} darling.\n" > > (and with some luck, that even fails :)? I fail to understand what you mean. > >And you even need the 'scalar' if you are using ${\(EXPR)}, as > >\ doesn't propagate context; it provides list context. > > But > > ${\foo} > > (as in your example) is still shorter than > > @{[foo]} > > (agreed however that the latter looks nicer). Yeah, but \ has quite a high priority. Higher than most binary operators. Most expressions you'd need to parenthesize. Abigail