bcarnazzi has asked for the wisdom of the Perl Monks concerning the following question:
I'd like to write a sub that I could use like this :
display_thing foreach(@things);
having $_ passed to display_thing.
Actually, I need to write :
display_thing $_ foreach(@things);
and my sub looks like this :
Is there a way to do this ?sub display_thing { my ($t) = @_; print $t; }
Thank you,
Bruno.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Is it possible to write a sub that understand default variables ?
by Corion (Patriarch) on Dec 24, 2007 at 11:27 UTC | |
by dcd (Scribe) on Dec 24, 2007 at 15:13 UTC | |
by bcarnazzi (Novice) on Dec 24, 2007 at 13:13 UTC | |
|
Re: Is it possible to write a sub that understand default variables ?
by FunkyMonk (Bishop) on Dec 24, 2007 at 11:24 UTC | |
|
Re: Is it possible to write a sub that understand default variables ?
by ikegami (Patriarch) on Dec 24, 2007 at 17:30 UTC | |
by Corion (Patriarch) on Dec 24, 2007 at 17:37 UTC | |
by ikegami (Patriarch) on Dec 24, 2007 at 18:36 UTC |