in reply to Re^2: NEXT statement in for loop
in thread NEXT statement in for loop

Why not? (And why don’t you try it?)

use strict; use warnings; use Data::Dump; my %pic = ( R0 => [ 5, 4 ], R2 => [ 3, 2 ] ); dd \%pic;

Output:

16:03 >perl 1651_SoPW.pl { R0 => [5, 4], R2 => [3, 2] } 16:03 >

See perlreftut and especially perldsc#HASHES-OF-ARRAYS.

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Replies are listed 'Best First'.
Re^4: NEXT statement in for loop
by Anonymous Monk on Jun 06, 2016 at 09:07 UTC

    Yes, tried and worked

    Pasting the final code

    my @r = qw/h1 h2/ ; my $rh = JT->new( host => $r[0] ); my $rh = JT->new( host => $r[1] ); my $output; my $key; my $value; my @routers =($r[0], $r[1]); my @router = ( "R0", "R1", "R2" ); my %fpc = ( R0 => [5,4], R1 => [3,2], R2 => [1,0], ); my %pic = ( R0 => [5,4], R1 => [3,2], R2 => [1,0], ); ); @router = ( "R0", "R1", "R2" ); for my $rh (@routers) { my $r = shift(@router); print "value of r is $r\n"; my $count = 0; for my $f (@{ $fpc{$r} }) { # for my $p (@{ $pic{$r} }) { my $p = (@{ $pic{$r} })[$count]; print "request chassis pic offline fpc-slot $f pic-slot $p +\n"; $count++; #} } }

    . Thanks all