Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Move data into AoH

by VinsWorldcom (Vicar)
on Sep 24, 2013 at 21:05 UTC ( #1055544=note: print w/ replies, xml ) Need Help??


in reply to Move data into AoH

How are you getting / generating the text file?

If the name / value pairs are separated by '=>' and the values are quoted, this can be done with something as simple as eval:

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my @array = @{eval <DATA>}; print Dumper \@array; __DATA__ [{field1=>'value1',field2=>'value2',field3=>'value3'},{field1=>'value4 +',field2=>'value5',field3=>'value6'},{field1=>'value7',field2=>'value +8',field3=>'value9'}]

And the output:

VinsWorldcomC:\Users\VinsWorldcom\tmp> test.pl $VAR1 = [ { 'field1' => 'value1', 'field2' => 'value2', 'field3' => 'value3' }, { 'field1' => 'value4', 'field2' => 'value5', 'field3' => 'value6' }, { 'field1' => 'value7', 'field2' => 'value8', 'field3' => 'value9' } ];


Comment on Re: Move data into AoH
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (14)
As of 2015-07-29 13:36 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