Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
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 drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2016-12-06 10:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (101 votes). Check out past polls.