Skip to content

Instantly share code, notes, and snippets.

@ctfliblime
Created October 10, 2011 13:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ctfliblime/1275289 to your computer and use it in GitHub Desktop.
Save ctfliblime/1275289 to your computer and use it in GitHub Desktop.
This one will work on Perl 5.8 (and probably much earlier)
#!/usr/bin/env perl
use strict ;
use warnings;
use locale ;
my @table=(1,2,3,8,5,8,0,4) ;
my @places ;
# Max value
my $max = (sort @table)[-1];
# Position
for my $index (0..$#table) {
push @places, $index if $table[$index] == $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