Re: Naming the @{[]} operator
Ted Zlatanov <[email protected]> Thu, 13 Jul 2006 10:45:52 -0400
| Newsgroups | gmane.comp.lang.perl.fun |
|---|---|
| Organization | Теодор Златанов @ Cienfuegos |
| Message-ID | <[email protected]> |
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