In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Smoot Carl-Mitchell) writes: >On Fri, 02 Apr 2004 10:37:14 -0600 >"JupiterHost.Net" <[EMAIL PROTECTED]> wrote: > >> It just occurred to me that many Perl functions use $_ if not other >> value is supplied. chomp for instance..., which is very handy... >> >> If one wanted to write a function that used either the given argument >> or $_ how would you do that? > >$_ is global, so do something like: > >sub test { > > my $arg; > $arg = shift or $arg = $_; >}
Same problem as the last suggestion. sub test { my $arg = (@_ ? shift : $_); } -- Peter Scott http://www.perldebugged.com/ *** NEW *** http://www.perlmedic.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>