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

A hash will help,

my %hsh; push @{$hsh{$data[$_]}}, $_ for 0..$#data; for (keys %hsh) { printf '$data[%d] and $data[%d] have the same value!!', @{$hsh{$_}} if @{$hsh{$_}} == 2; }
%hsh becomes a Hash-of-Arrays with push, then we just look for arrays bigger than 1. I restricted that to 2 for the example.

Update: tinita++, corrected.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re: Re: How do I get the position of the same value in array or list.
by tinita (Parson) on Apr 07, 2004 at 08:08 UTC
    Zaxo, you mean the right thing, but it should be @{ $hash{key} } instead of @$hash {key}, so:
    push @{ $hsh{$data[$_]} }, $_ for 0..$#data;