Re: Using $_ in a function if no argument is passed

2004-04-04 Thread R. Joseph Newton
Paul Johnson wrote: > On Sat, Apr 03, 2004 at 11:53:59AM -0800, R. Joseph Newton wrote: > > > Paul Johnson wrote: > > > > > $_ = "Leave me alone!"; > > > $s = "0"; > > > > Better yet: > > $lower_or-mixed_case_string = 'o'; > > I worry that you may have missed the point of the example, which was th

Re: Using $_ in a function if no argument is passed

2004-04-04 Thread Paul Johnson
On Sat, Apr 03, 2004 at 11:53:59AM -0800, R. Joseph Newton wrote: > Paul Johnson wrote: > > > $_ = "Leave me alone!"; > > $s = "0"; > > Better yet: > $lower_or-mixed_case_string = 'o'; I worry that you may have missed the point of the example, which was the value of the variable being passed in

Re: Using $_ in a function if no argument is passed

2004-04-03 Thread JupiterHost.Net
Thank you to all the responders! I love getting insights like this, Yes I will not use that method (see subject), just love lots of points of view to better my angle :) Thanks again ;p Lee.M - JupiterHost.Net -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAI

Re: Using $_ in a function if no argument is passed

2004-04-03 Thread Smoot Carl-Mitchell
On Sat, 03 Apr 2004 11:49:02 -0800 "R. Joseph Newton" <[EMAIL PROTECTED]> wrote: > > If one wanted to write a function that used either the given > > argument or$_ how would you do that? > > Don't > > > myfunc($myvalue); > > or > > myfunc; #uses the current value of $_ > > > > sub myfunc { >

Re: Using $_ in a function if no argument is passed

2004-04-03 Thread R. Joseph Newton
Paul Johnson wrote: > > $_ = "Leave me alone!"; > $s = "0"; Better yet: $lower_or-mixed_case_string = 'o'; > to_upper $lower_or-mixed_case_string; With intelligent use of the editing facilities available, extra characters do not cost much. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED]

Re: Using $_ in a function if no argument is passed

2004-04-03 Thread R. Joseph Newton
"JupiterHost.Net" wrote: > Hello List, > > It just occurred to me that many Perl functions use $_ if not other > value is supplied. chomp for instance..., which is very handy... Yes. Like the peaceful feeling that comes the first time one shoots up junk. > If one wanted to write a function that

Re: Using $_ in a function if no argument is passed

2004-04-03 Thread Smoot Carl-Mitchell
On Sat, 3 Apr 2004 11:04:35 -0600 "Charles K. Clarkson" <[EMAIL PROTECTED]> wrote: > Smoot Carl-Mitchell <[EMAIL PROTECTED]> wrote: > : > >sub test { > : > > > : > > my $arg; > : > > $arg = shift or $arg = $_; > : > >} > : > > : > Same problem as the last suggestion. > : > : And what specifical

RE: Using $_ in a function if no argument is passed

2004-04-03 Thread Charles K. Clarkson
Smoot Carl-Mitchell <[EMAIL PROTECTED]> wrote: : : On 3 Apr 2004 14:40:43 - : [EMAIL PROTECTED] (Peter Scott) wrote: : : > In article <[EMAIL PROTECTED]>, : > [EMAIL PROTECTED] (Smoot Carl-Mitchell) writes: : > > : > >sub test { : > > : > > my $arg; : > > $arg = shift or $arg = $_; : > >

Re: Using $_ in a function if no argument is passed

2004-04-03 Thread Smoot Carl-Mitchell
On 3 Apr 2004 14:40:43 - [EMAIL PROTECTED] (Peter Scott) wrote: > 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 us

Re: Using $_ in a function if no argument is passed

2004-04-03 Thread Peter Scott
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 han

Re: Using $_ in a function if no argument is passed

2004-04-02 Thread Paul Johnson
On Fri, Apr 02, 2004 at 07:18:25AM -1000, Beau E. Cox wrote: > sub to_upper > { > # point to passed arg or caller's $_ > my $arg = $_[0] ? \$_[0] : \$_; my $arg = @_ ? \$_[0] : \$_; > # modify in place > $$arg = uc $$arg; > } $_ = "Leave me alone!"; $s = "0"; to_upper $s;

Re: Using $_ in a function if no argument is passed

2004-04-02 Thread Smoot Carl-Mitchell
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

Re: Using $_ in a function if no argument is passed

2004-04-02 Thread Beau E. Cox
On Friday 02 April 2004 07:04 am, Beau E. Cox wrote: > On Friday 02 April 2004 06:37 am, JupiterHost.Net wrote: > > Hello List, > > > > 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 w

Re: Using $_ in a function if no argument is passed

2004-04-02 Thread Beau E. Cox
On Friday 02 April 2004 06:37 am, JupiterHost.Net wrote: > Hello List, > > 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 wou

Using $_ in a function if no argument is passed

2004-04-02 Thread JupiterHost.Net
Hello List, 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? myfunc($myvalue); or myfunc; #uses the current v