steves has asked for the wisdom of the Perl Monks concerning the following question:
When writing a function with a & prototype like this:
how come when using it, this works:sub foo(&@) { my $code = shift; # whatever ... }
but this doesn't:foo {$_ =~ /foo/} $a, $b, $c;
foo({$_ =~ /foo/} $a, $b, $c);
I found a few references searching Google but no explanation that satisfies me. After all, I can call built-ins either way, e.g., this works:
Nothing in the Camel book either unless I just can't find it. I need enlightenment.my @x = grep({$_ =~ /foo/} @list);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: & function prototypes and parens
by demerphq (Chancellor) on Feb 08, 2003 at 14:13 UTC | |
by steves (Curate) on Feb 08, 2003 at 15:27 UTC | |
by demerphq (Chancellor) on Feb 08, 2003 at 23:05 UTC | |
|
Re: & function prototypes and parens
by tall_man (Parson) on Feb 09, 2003 at 01:30 UTC | |
by steves (Curate) on Feb 09, 2003 at 01:39 UTC |