in reply to Reliably simulating 5.10 say()
Hello hlc, and welcome to the Monastery!
This is one case where prototypes are actually useful. From perlsub#Prototypes:
As the last character of a prototype, or just before a semicolon, a @ or a %, you can use _ in place of $: if this argument is not provided, $_ will be used instead.
Hence:
#! perl use strict; use warnings; sub say (_) # <-- ADD THIS { print @_, "\n"; } my @a = qw(1 2 3); say for @a;
Output:
0:16 >perl 1151_SoPW.pl 1 2 3 0:16 >
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Reliably simulating 5.10 say()
by LanX (Saint) on Feb 08, 2015 at 15:08 UTC | |
by Athanasius (Archbishop) on Feb 08, 2015 at 15:29 UTC | |
|
Re^2: Reliably simulating 5.10 say()
by choroba (Cardinal) on Feb 08, 2015 at 15:57 UTC | |
|
Re^2: Reliably simulating 5.10 say()
by ikegami (Patriarch) on Feb 08, 2015 at 15:41 UTC | |
|
Re^2: Reliably simulating 5.10 say()
by hlc (Initiate) on Feb 08, 2015 at 14:18 UTC | |
by Laurent_R (Canon) on Feb 08, 2015 at 17:51 UTC | |
by Laurent_R (Canon) on Feb 08, 2015 at 15:00 UTC | |
by hlc (Initiate) on Feb 08, 2015 at 15:15 UTC |