Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: need help to create array dynamically

by choroba (Canon)
on Jan 24, 2013 at 09:42 UTC ( #1015124=note: print w/ replies, xml ) Need Help??


in reply to need help to create array dynamically

To dynamically create arrays, just create an array of arrays. See perldsc - Perl Data Structures Cookbook and perllol - Manipulating Arrays of Arrays in Perl for details.

#!/usr/bin/perl use warnings; use strict; use Data::Dumper; my @arrays; my $count = -1; while (<DATA>) { chomp; $count++ if $_ eq '['; next if /[][]/; push @{ $arrays[$count] }, $_; } print Dumper \@arrays; __DATA__ [ aaaa bbbbb ] [ ccc dddd eeeee ] [ f ]
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ


Comment on Re: need help to create array dynamically
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (14)
As of 2015-07-31 21:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (282 votes), past polls