hello,
In a array @tab I get $tab[n], but I don't know n.

I want to get $tab[n + 1].

I found two ways (there are probably better ways;-)) 

1:
@tab = qw/bar tabou island mong turlut foo perl/;
($mot1) = grep /tu/, @tab;
print $mot1, "\n";
$index = 0;
foreach (@tab) {
last if $tab[$index] eq $mot1;
++$index;
}
print $tab[++$index], "\n";

2:
%hash = qw/0 bar 1 tabou 2 island 3 mong 4 turlut 5 foo/;
%hash2 = reverse %hash;
($mot2) = grep /m/, values(%hash);
print $mot2, "\n";
print $hash{++$hash2{$mot2}}, "\n";

which is the better way betwen 1 and 2 ?  
Is there a straightforward way ?

tia
-- 
GĂ©rard 


-- 
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