Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: How do I parse CPAN .meta files

by davido (Archbishop)
on Jan 19, 2013 at 01:59 UTC ( #1014161=note: print w/replies, xml ) Need Help??


in reply to How do I parse CPAN .meta files

That's JSON. JSON ought to do the trick, or minimally JSON::Tiny:

use Data::Dumper; use JSON::Tiny; my $json = do { local $/ = undef; <DATA>; }; my $hash = JSON::Tiny->new->decode($json); print Dumper $hash; __DATA__ { "abstract" : "Regexp Capture Filter For Message::Passing", "author" : [ "chenryn <rao.chenlin@gmail.com>" ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 6.62, CPAN::Meta::Con +verter version 2.112150", "license" : [ "unknown" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Message-Passing-Filter-Regexp", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : 0 } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : 0 } }, "runtime" : { "requires" : { "Config::Tiny" : 0, "JSON::Types" : 0, "Message::Passing" : "0.11", "Regexp::Log" : 0 } } }, "release_status" : "stable", "version" : "0.02" }

I won't bother dumping the output here, but it does work. ;)

As for understanding the spec itself, there's CPAN::Meta::Spec

Or more minimally, as a one-liner: perl -0777 -MData::Dumper -MJSON::Tiny -e 'print Dumper( JSON::Tiny->new->decode( <> ) );' file.txt


Dave

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1014161]
help
Chatterbox?
[Eily]: google tells me 1662 km ...
[LanX]: Nancy? Somewhere near Metz ...
[Eily]: must be km farenheit or something :P
[Eily]: wow, don't say that in Nancy LanX :P
[erix]: maybe you used the car routes, I used the walking routes
[Eily]: there's a rivalry between the two cities, so defining one in terms of the other might not be well received
[Eily]: erix well I did click on the walking icon
LanX giggles!
[LanX]: Eily I'm duing this constantly with people from rival cities ...MUCHO fun!
[Eily]: The best example of that is the TGV, they couldn't decide who would get it so it's in the middle of nowhere halfway between the two

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (13)
As of 2017-12-13 15:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (369 votes). Check out past polls.

    Notices?