use strict; use warnings; # you can initialize this any way you wish, this is proof of concept. my @source = ( 5, 53, 24, 38 ); my $maxseen = 0; my $seen_at = 0; my $cntr = 0; for ( @source ) { if ( $_ > $maxseen ) { $maxseen = $_; $seen_at = $cntr; } ++$cntr; }