go ahead... be a heretic PerlMonks

### Comment on

 Need Help??
Here you go:

This is how one can find a maximum number in an array iteratively and recursively in Perl

```
#!/usr/bin/perl

my (@setOfnumbers);

@setOfnumbers = ( 9, 7, 90, 3, 8, 412, 67, 2, 45, 53, 1, 3,89 );

print "Finding maximum number iteratively ",
getMaximumNumber(@setOfnumbers) , "\n";
print "Finding maximum number recursively ",
findMaximumNumber(@setOfnumbers) , "\n";

#Finding maximum number iteratively
sub getMaximumNumber{
my (\$maximumNumber);
\$maximumNumber = @_[0];
foreach(@_){
if (\$_ > \$maximumNumber){
\$maximumNumber = \$_;
}
}
return \$maximumNumber;
}

#Finding maximum number recursively
sub findMaximumNumber{

my (\$maximumNumber);

if (@_ == 1){
\$maximumNumber = shift(@_);
return \$maximumNumber;
}
else{
\$maximumNumber = shift(@_);
return (findMaximumNumber(@_) > \$maximumNumber)
? findMaximumNumber(@_) : \$maximumNumber;
}

}

In reply to Re^4: Finding the max()/min() by fnicholas
in thread Finding the max()/min() by dragonchild

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

• Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
• Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
• Read Where should I post X? if you're not absolutely sure you're posting in the right place.
• Posts may use any of the Perl Monks Approved HTML tags:
a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
• You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
 For: Use: & & < < > > [ [ ] ]
• Link using PerlMonks shortcuts! What shortcuts can I use for linking?

Create A New User
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2017-07-26 09:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
I came, I saw, I ...

Results (387 votes). Check out past polls.