Birgit Kellner wrote:
> 
> my %hash = ('firstkey' => 'firstvalue',
>         'secondkey' => 'secondvalue',
>         'thirdkey' => 'thirdvalue');
> my @array = ('secondkey', 'other element', 'still other element',
> 'firstkey');
> my @index_array;
> foreach my $element (@array) {
>         # QUESTION: here I'd like to have some code that returns the index number
> of $element, which I'd store in $index
>         if ($hash{$element}) {
>                 push (@index_array, $index);
>                 }
>         }
> 
> Any suggestions would be greatly appreciated,

Simple solution is
...
my $index = 0;
foreach my $element (@array) {
        if (...) {
                ...
        }
        $index++;
}

Greetings,
Andrea

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to