Skip to content

Instantly share code, notes, and snippets.

@MaximeD
Created October 10, 2011 08:46
Show Gist options
  • Save MaximeD/1274883 to your computer and use it in GitHub Desktop.
Save MaximeD/1274883 to your computer and use it in GitHub Desktop.
Writing perl as perl
#!/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