Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Getting individual lists from a bigger list

by poj (Abbot)
on Jul 04, 2013 at 10:13 UTC ( [id://1042418]=note: print w/replies, xml ) Need Help??


in reply to Getting individual lists from a bigger list

If you want to keep @bigList unchanged then you could use another array to keep start and end positions for each list added, something like this

#!perl; use strict; use warnings; my @test = ([ qw(A B C) ],[ qw(1 2 3 4)], [qw( x y )]); my @bigList = (); my @chunk = (); for my $ar (@test){ my @templist = @$ar; my $start = scalar @bigList; push @bigList,@templist; my $end = $#bigList; push @chunk,[$start,$end]; } print "@bigList \n"; # each smaller list for my $ar (@chunk){ my ($start,$end) = @$ar; print "@bigList[$start..$end] \n"; }
poj

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-26 07:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found