in reply to Explanation of commonly used Perl
Unroll it, bit by bit:
| @_ | We'll take the parameters passed to the sub.. |
| {@_} | ..and make an anonymous hash out of them. |
| {{@_}}{ ... } | ..now we're going to dereference this hashref.. |
| @{{@_}}{qw/ ... /} | ..but take a slice of it when we do so; |
| @{{@_}}{qw/foo bar/} | Specifically, we'll extract the foo and bar values from the hashref.. |
| my ($foo, $bar) = @{{@_}}{qw/foo bar/} | ..and put them into $foo and $bar |
Essentially, the code is equivilent to the following, but avoids the %args variable:
sub foobar { my %args = @_; my $foo = $args{foo}; my $bar = $args{bar}; }
perl -pe '"I lo*`+$^X$\"$]!$/"=~m%(.*)%s;$_=$1;y^`+*^e v^#$&V"+@( NO CARRIER'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Explanation of commonly used Perl
by perrin (Chancellor) on Apr 16, 2002 at 22:25 UTC | |
by Chmrr (Vicar) on Apr 16, 2002 at 22:30 UTC |