Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^3: I think Perl ruined me as a programmer

by Anonymous Monk
on Nov 14, 2008 at 23:51 UTC ( #723752=note: print w/replies, xml ) Need Help??


in reply to Re^2: I think Perl ruined me as a programmer
in thread I think Perl ruined me as a programmer

The function should be:
sub min { my $min = shift; foreach (@_) { $min = $_ if $_ < $min; } return $min; }

Replies are listed 'Best First'.
Re^4: I think Perl ruined me as a programmer
by Anonymous Monk on Apr 12, 2010 at 05:36 UTC
    or, to avoid warnings about the occasional undefs in your arg list:
    sub min { my $min; for (@_) { next unless defined; $min = $_ if $_ < $min } $min }
      oops, sorry..
      sub min { my $r; for (@_) { next unless defined; $r = $_ if !defined($r) || $_ < $r } $r }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://723752]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2023-06-09 11:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you go to conferences?






    Results (35 votes). Check out past polls.

    Notices?