in reply to Re: replacing say function
in thread replacing say function
I like bart's (edited to correct name) solution except you may want to add a prototype so you can call the sub without parentheses around the arguments.
>>>Update>>>: On further testing, I guess you don't need a prototype. The trick is to define the sub above the statement where you call it. The following works just as well for me:#!/usr/bin/perl use strict; use warnings; use 5.008; sub say (@){ local $\ = "\n"; print @_ ? @_ : $_; } say 'Hey';
#!/usr/bin/perl use strict; use warnings; use 5.008; sub say{ local $\ = "\n"; print @_ ? @_ : $_; } say 'Hey';
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: replacing say function
by bart (Canon) on Feb 11, 2011 at 22:45 UTC | |
|
Re^3: replacing say function
by cyber-guard (Acolyte) on Feb 13, 2011 at 18:09 UTC |