in reply to Re^3: Reliably simulating 5.10 say()
in thread Reliably simulating 5.10 say()

#!/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";
The error for above:
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.