Re: Looping through an anonymous array of arrays



"(Randal" == (Randal L Schwartz) <merlyn@xxxxxxxxxxxxxx> writes:

(Randal> my @items = @$arrayRef;
(Randal> while (@items) {
(Randal> if (ref $items[0]) {
(Randal> if (ref $items[0] eq "ARRAY") {
(Randal> unshift @items, @{shift @items}; # replace arrayref with contents
(Randal> redo;

next, not redo. Sorry. Otherwise, [] is improperly undef-printed. :)

(Randal> }
(Randal> die "cannot handle ref of type ", ref $items[0];
(Randal> }
(Randal> print shift @items;
(Randal> }

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@xxxxxxxxxxxxxx> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
.



Relevant Pages

  • Re: ntpdate problem
    ... why are you using ntpdate and not just ntpd? ... Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. ...
    (freebsd-questions)
  • Re: Like it or not, Theo has a point... freebsd is shipping export-restricted software in the co
    ... RW> required by the appropriate agencies. ... Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. ...
    (freebsd-questions)
  • Re: Convert all packages to ports
    ... Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. ... See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion ...
    (freebsd-questions)
  • Re: Not getting all the element.
    ... Meta question: Did you see this combination of on a web page or book ... Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. ... See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion ...
    (perl.beginners)
  • Re: Help booting FreeBSD with a ZFS root filesystem
    ... Ross> That seems to have been the problem. ... Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. ... See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion ...
    (freebsd-questions)