Re: Looping through an anonymous array of arrays

[email protected] ("Dr.Ruud")
Newsgroups perl.beginners
Organization Chaos rules.
Message-ID <[email protected]>
"Rodrick Brown" schreef:

> my $arrayRef = [ 1, 2, 3, ['a', 'b', 'c', ["Hello"] ]];
> 
> I have no problem returning single elements but how would one walk
> this list of elements with say a for loop?

Start writing it differently, maybe like:

  my $data = [
      1,
      2,
      3,
      [ 'a',
        'b',
        'c',
        [ 'Hello' ],
      ],
  ];

or compacter like: 

  my $data = [ qw/1 2 3/, 
               [ qw/a b c/, 
                 [ qw/Hello/ ],
               ],
             ];

-- 
Affijn, Ruud

"Gewoon is een tijger."
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.