Created
October 10, 2011 08:46
-
-
Save MaximeD/1274883 to your computer and use it in GitHub Desktop.
Writing perl as perl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict ; | |
use locale ; | |
my @table=(1,2,3,8,5,8,0,4) ; | |
my @places ; | |
my ($index,$value) ; | |
# Max value | |
my $max = (sort @table)[-1]; | |
# Position | |
while (($index, $value) = each @table){ | |
push @places, $index if $value == $max; | |
} | |
print "Max value is \"$max\", at position(s) " . join(", ", @places) . "\n" ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment