Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: need help to create array dynamically

by choroba (Abbot)
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 lurking in the Monastery: (11)
As of 2014-09-17 16:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (91 votes), past polls