Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Move data into AoH

by hdb (Prior)
on Sep 25, 2013 at 06:24 UTC ( #1055619=note: print w/replies, xml ) Need Help??


in reply to Move data into AoH

JSON is a good starting point, but it requires field names and values in quotes. See the following code which does not work due to lack of quotes:

use strict; use warnings; use JSON; use Data::Dumper; my $json = <<EOT; [{field1:value1,field2:value2,field3:value3} ,{field1:value4,field2:value5,field3:value6} ,{field1:value7,field2:value8,field3:value9} ] EOT my $data = decode_json( $json ); print Dumper $data;

If you can't write a simple regex to fix the quote issue, I suggest to look into Text::CSV. With the help of that module you might be able to parse your text file. It really depends on how quotes, colons and commas interact in your file.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1055619]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2017-02-25 21:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (368 votes). Check out past polls.