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.

#!/usr/bin/perl use strict; use warnings; use 5.008; sub say (@){ local $\ = "\n"; print @_ ? @_ : $_; } say 'Hey';
>>>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';

Replies are listed 'Best First'.
Re^3: replacing say function
by bart (Canon) on Feb 11, 2011 at 22:45 UTC
    You don't need a prototype for that. All you need to do is to define the sub before you call it — or put it in a module that you use. Same thing.
Re^3: replacing say function
by cyber-guard (Acolyte) on Feb 13, 2011 at 18:09 UTC
    Sweet! Thanks, all done now :)