in reply to Re^2: Help extracting pattern of data
in thread Help extracting pattern of data
The DATA handle can be read using: <DATA> ...the point being that it's not <_DATA_>, it's <DATA>. Then at the end of your script, it is not _DATA_ (with a single underscore on either side), it's __DATA__, with two underscores on each side. At first I thought maybe you just made a typo, but I'm seeing you do it repeatedly, so it's worth mentioning.
As for decoding the JSON first, YES. It doesn't need to be a pattern matching problem (which is almost always much more difficult than people expect) when there are perfectly good JSON parsing modules that will return a structure that you can simply traverse, iterate over, or manipulate however you wish, easily.
Here's how I would start:
use strict; use warnings; use JSON; use Data::Dumper; my $j = JSON->new; my $structure = $j->decode( do { local $/ = undef; <DATA> } ); print Dumper $structure; __DATA__ JSON here.....
Then after getting a look at how my data is structured, I could plan how I want to work with it.
If JSON and JSON::XS seem to heavy for you, try JSON::Tiny, in which case: my $structure = JSON::Tiny->new->decode( ..... );
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Help extracting pattern of data
by spikeinc (Acolyte) on Jan 27, 2014 at 04:21 UTC | |
|
Re^4: Help extracting pattern of data
by spikeinc (Acolyte) on Jan 27, 2014 at 04:39 UTC | |
by AnomalousMonk (Archbishop) on Jan 27, 2014 at 04:45 UTC | |
by spikeinc (Acolyte) on Jan 27, 2014 at 05:11 UTC | |
by spikeinc (Acolyte) on Jan 27, 2014 at 08:17 UTC | |
by spikeinc (Acolyte) on Jan 27, 2014 at 08:36 UTC |