lakshu has asked for the wisdom of the Perl Monks concerning the following question:
In below program I am expecting the value like 3, 6,6,10, 10 can anyone help
use strict; use warnings; sub min_and_max { my (@numbers); @numbers = @_; my ($min, $max, @ret1); $min = $numbers[0]; $max = $numbers[0]; foreach my $i (@numbers) { if ($i >= $max) { return push my(@ret1), $i; } } return (@ret1); } my (@test_array); @test_array = (3,6,,7,6,3,10,5,6,2, 10); my @ret = min_and_max(@test_array);
In this program I am expecting the value like 3, 6,6,10, 10 can anyone help
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: how to choose the greater or equal number in array
by Discipulus (Canon) on Oct 12, 2017 at 19:20 UTC | |
|
Re: how to choose the greater or equal number in array
by 1nickt (Canon) on Oct 12, 2017 at 18:16 UTC | |
|
Re: how to choose the greater or equal number in array
by Your Mother (Archbishop) on Oct 13, 2017 at 16:56 UTC | |
|
Re: how to choose the greater or equal number in array
by thanos1983 (Parson) on Oct 12, 2017 at 20:49 UTC | |
|
Re: how to choose the greater or equal number in array
by Anonymous Monk on Oct 13, 2017 at 14:07 UTC |