awohld has asked for the wisdom of the Perl Monks concerning the following question:
So line 4: "my($max_so_far) = shift @_;" is a "$max_so_far" list variable? If so why is it a list variable, just because it's in parenthesis? Could it just have been typed as "my $max_so_far" and just let it be a scalar?$maximum = &max(3, 5, 10, 4, 6); sub max { my($max_so_far) = shift @_; foreach (@_) { if ($_ > $max_so_far) { $max_so_far = $_; } } $max_so_far; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Need to check my understanding of this code...
by davidrw (Prior) on Sep 04, 2005 at 19:12 UTC | |
|
Re: Need to check my understanding of this code...
by borisz (Canon) on Sep 04, 2005 at 19:04 UTC | |
by dorward (Curate) on Sep 04, 2005 at 19:10 UTC | |
by borisz (Canon) on Sep 04, 2005 at 19:36 UTC | |
by dorward (Curate) on Sep 04, 2005 at 23:25 UTC | |
|
Re: Need to check my understanding of this code...
by merlyn (Sage) on Sep 04, 2005 at 19:23 UTC | |
by awohld (Hermit) on Sep 05, 2005 at 03:38 UTC |