The error for above:#!/usr/bin/env perl + + use strict; + use warnings; + + sub say (_) { + print @_, "\n"; } + + my @a = qw(1 2 3); + + # using implicit $_ does not work: + say foreach (@a); + + # ...and of course explicit $_ works. + say $_ foreach (@a); + + # works: + say "uncle bob";
Illegal character in prototype for main::say : _ at a.pl line 6. Not enough arguments for main::say at a.pl line 13, near "say foreach +" Malformed prototype for main::say: _ at a.pl line 16.
In reply to Re^4: Reliably simulating 5.10 say()
by hlc
in thread Reliably simulating 5.10 say()
by hlc
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |