On 13 Jul 2006, [EMAIL PROTECTED] wrote:
On 7/7/06, Jerrad Pierce <[EMAIL PROTECTED]> wrote:
>
>> perl -le 'print "@{[time]}"'
>
> What the advantage the above over this:
>
> perl -le 'print time'
>
> Could I please get some more examples?
Let's say you want to print some help:
my %commands = ( get => sub { ... },
set => sub { ... },
... etc ...
);
if ($help_requested)
{
print "Available commands: @{[keys %commands]}";
exit;
}
Generally, it's handy when you want to interpolate complex info into a
string without intermediate steps, since you know you won't be reusing
that info. I use it a lot for help, since it's usually (Unix-style on
-h) generated once and then the program exits in many of my scripts.
Ted