On Fri, 20 May 2005, Peter Rabbitson wrote:

> my @lsit = qw(a b c d);
> my %indexes;
>
> my $current_index = 0;
>
> foreach my $element (@list) {
>       $indexes{$element} = $current_index;
>       ++ $current_index;
> }

Ah. Maybe this?

    for (0 .. $#list) {
        $indexes{$list[$_]} = $_;
    }

Closer?


-- 
Chris Devers

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to