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

Re^3: How to read CPAN documentation

by muba (Priest)
on Jul 06, 2012 at 17:33 UTC ( #980334=note: print w/replies, xml ) Need Help??

in reply to Re^2: How to read CPAN documentation
in thread How to read CPAN documentation

Send it to Perl how? Through CGI? Over a socket? From a file? To the script's STDIN? Those all require a slightly different approach, but generally you'll eventually end up with the whole JSON data in a variable, let's say $json. Then you use one of the JSON decoding mechanisms - I'd go for the first one in the synopsis that seems to match the description, so you'd have a line like $perl_data_structure = decode_json $json;.

Now, what $perl_data_structure looks like depends on what the outermost element of the JSON data was. Was it a map? Then $perl_data_structure will be a hash ref. Was it an array? Then $perl_data_structure will be an array ref. I am assuming you know what sort of data you want to send to your script and what it's formatted like, so this shouldn't be too much of an obstacle.

Inserting it into a database, again, can't happen without asking yourself some questions, first. What do the tables in the database look like? What tables are there, what columns do they have and what data types go into those columns? Which elements from the incoming data do I want to insert? How do I transform the data structure into SQL -- but note that at this point you're no longer dealing with JSON. All you have is just an ordinary complex Perl data structure.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://980334]
[1nickt]: Wow, sometimes "Perl programming" hardly involves Perl! I just spent a couple of days implementing some features in the CPAN Testers API and it was 90% hand-editing JSON Swagger config and test data structs, and writing doc. Maybe that's just the sign of
[Discipulus]: rethatching? a real, old cottage?
[1nickt]: ... a well-crafted project that's easy to extend.
[1nickt]: Discipulus I believe virtualsue *is* that fortunate. @10:42Z yesterday "my view this morning is of a chap stuffing straw in my roof" ...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2017-11-21 11:55 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (297 votes). Check out past polls.