my %fpc = ( R0 => { fpc1 => 5, fpc2 => 4, }, R2 => { fpc1 => 3, fpc2 => 2, }, R3 => { fpc1 => 1, fpc2 => 0, }, ); my %pic = ( R0 => { pic1 => 5, pic2 => 4, }, R2 => { pic1 => 3, pic2 => 2, }, R3 => { pic1 => 1, pic2 => 0, }, ); @router = ( "R0", "R2", "R3" ); for my $rh (@routers) { my $r = shift(@router); print "value of r is $r\n"; OUTER: for my $f (values %{ $fpc{$r} }) { INNER: for my $p (values %{ $pic{$r} }) { print "request chassis pic offline fpc-slot $f pic-slot $p +\n"; next OUTER; } } }
Output is
value of r is R0
request chassis pic offline fpc-slot 5 pic-slot 4
request chassis pic offline fpc-slot 4 pic-slot 4
I thought it will take first value of $pic{R0}, which is 5 but it is taking $pic{R0} second value. Also, is there a way to increment the second "for" loop also. In the second output, "request chassis pic offline fpc-slot 4 pic-slot 4", it is taking the correct values for fpc, but pic it is still retaining the old value 4. Is there a way to solve it?
In reply to NEXT statement in for loop by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |