Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: Parsing data from JSON response file.

by Marshall (Canon)
on Apr 13, 2020 at 03:12 UTC ( [id://11115412]=note: print w/replies, xml ) Need Help??


in reply to Re: Parsing data from JSON response file.
in thread Parsing data from JSON response file.

Good idea. That is actually one of the first things I did when running the code. And then came the realization that $key wasn't used anywhere within the loop!
for my $key ( keys %$data ) { print "key = $key\n"; #debug my $zip = $data->{'zip'}; my $descri = $data->{'happen'}[0]->{'descri'}; my $extra_name = $data->{'notas'}[0]->{'ExtraName'}; print "\n $zip - $descri - $extra_name\n"; }
I guess this is "off topic", but a feature of Perl.

If you have a constant like: use constant DEBUG => 1; and then have a statement like print "whatever line(s)" if DEBUG;, Perl is smart enough to eliminate this statement from the executable code when DEBUG is false (set to zero). For complex modules, I often leave code like that in the source. When I add a new feature, I turn debugging on. Print is your friend. I seldom need the Perl debugger.

Replies are listed 'Best First'.
Re^3: Parsing data from JSON response file.
by roboticus (Chancellor) on Apr 13, 2020 at 17:18 UTC

    Marshall:

    That's easy enough to verify with B::Concise:

    $ cat foo.pl use strict; use warnings; use constant DEBUG=>0; print "Foo bar!\n"; print "Baz\n" if DEBUG; $ perl -MO=Concise,-exec foo.pl 1 <0> enter 2 <;> nextstate(main 191 foo.pl:5) v:*,&,{,x*,x&,x$,$ 3 <0> pushmark s 4 <$> const[PV "Foo bar!\n"] s 5 <@> print vK 6 <;> nextstate(main 191 foo.pl:6) v:*,&,{,x*,x&,x$,$ 7 <@> leave[1 ref] vKP/REFC foo.pl syntax OK

    Yep, it's stripped out!

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-19 21:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found