Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

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

by Anonymous Monk
on Nov 14, 2008 at 23:51 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (6)
As of 2024-03-28 22:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found