---------- 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"'

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 :)?

>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).


Joerg

Reply via email to