Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: How to traverse a two dimentional array in a constructor?

by Anonymous Monk
on Jun 25, 2013 at 09:56 UTC ( #1040575=note: print w/replies, xml ) Need Help??


in reply to How to traverse a two dimentional array in a constructor?

The result of Dumper

It appears in other parts of your code you populate INTERFACE/ROUTINGTABLE in two dimensions correctly, so same deal to access it, perl way

my $ref = [ [ 1..3], [9..11] ]; for my $first ( @$ref ){ for my $item ( @$first ){ print $item; } } __END__ 12391011

The perl way :)

my $ref = [ [ 1..3], [9..11] ]; for my $xi ( 0 .. $#{ $ref } ){ for my $yi( 0 .. $#{ $ref->[ $xi] } ){ print $ref->[ $xi ][ $yi ]; } } __END__ 12391011

See also references quick reference, Data::Diver, Re: Parsing SOAP::Lite results (with Data::Diver)

Great, an update , just mark it How do I change/delete my post?

Replies are listed 'Best First'.
Re^2: How to traverse a two dimentional array in a constructor?
by Hossein (Acolyte) on Jun 25, 2013 at 10:43 UTC

    Thank you for your answer.

    When I work with multiple dimentional array, or nested hashes, everything works just fine. BUT here, when I try to do OO (newbe) I realy am in truble. What I can't do is to get the values on those objects which are stored in @fw in the tight way.

    I need to traverse @fw in order to display vales, but every time I try, it fails!

    I need help to know how shall I travers @fw to get currect values.

    $fw = [ $var1= bless( { 'INTERFACE' => [ [],[],[] ], 'NAME' => 'myname', 'DESCRIPTION' => undef, 'ROUTINGTABLE' => [ [],[],[] ] }, 'NT::FW' ); $var2= bless( { 'INTERFACE' => [ [],[],[] ], 'NAME' => 'myname', 'DESCRIPTION' => undef, 'ROUTINGTABLE' => [ [],[],[] ] }, 'NT::FW' ); ]

      ... I repeat myself ...

      maybe you want to show what you tried?

        Thank you for your help :)

        I found the problem.

        Regards,

        /HHK

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1040575]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2019-11-18 01:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (87 votes). Check out past polls.

    Notices?