Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: need help to create array dynamically

by clueless newbie (Hermit)
on Jan 24, 2013 at 13:10 UTC ( #1015166=note: print w/ replies, xml ) Need Help??


in reply to need help to create array dynamically

Doesn't the data look close to a data structure already? A few regexes and an eval ...

#!/usr/bin/perl use Data::Dumper; use strict; use warnings; local $/; my $data=<DATA>; $data=~s{\[}{[qw(}sg; $data=~s{\]}{)],}sg; eval '$data=\['.$data.']'; warn Data::Dumper->Dump([\$data],[qw(*data)]).' '; __DATA__ [ abc def ] [ ghi jkl mno ]

and we have ...

$data = \\[ [ 'abc', 'def' ], [ 'ghi', 'jkl', 'mno' ] ]; at pmdata.pl line 13, <DATA> chunk 1.


Comment on Re: need help to create array dynamically
Select or Download Code
Replies are listed 'Best First'.
Re^2: need help to create array dynamically
by Anonymous Monk on Jan 24, 2013 at 13:17 UTC

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (15)
As of 2015-07-29 12:15 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 (263 votes), past polls