in reply to How do I get the position of the same value in array or list.

#!/usr/bin/perl use strict; my %position; my @data = ( qw[orange strawberry apple orange banana orange apple coc +onut] ); my $pos = -1; foreach my $item (@data) { ++$pos; push (@{$position{$item}}, $pos); } foreach my $foo (keys %position) { if (scalar @{$position{$foo}} > 1) { print "$foo occurs on positions @{$position{$foo}}\n"; } } __OUTPUT__ apple occurs on positions 2 6 orange occurs on positions 0 3 5 END__OUTPUT__

pelagic
-------------------------------------
I can resist anything but temptation.