Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: need help to create array dynamically

by choroba (Chancellor)
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 ]
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2016-10-26 01:25 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (330 votes). Check out past polls.