Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
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


Comment on Re: How do I parse CPAN .meta files
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2014-09-16 11:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (13 votes), past polls