Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^3: Problem printing JSON type output

by jonathan.vanderwatt (Initiate)
on Jul 14, 2015 at 12:17 UTC ( #1134706=note: print w/replies, xml ) Need Help??


in reply to Re^2: Problem printing JSON type output
in thread Problem printing JSON type output

This seems to have solved my problem:

#!/usr/bin/perl $first=1; print "{"; print " \"data\":\n\t[\n"; my $filename = '/opt/scripts/bob_monitor.sh'; open(my $fh, '<:encoding(UTF-8)', $filename) or die "Could not open file '$filename' $!"; while (my $row = <$fh>) { chomp($row); for($row) { next if $row =~ /^cd|^#|^$|^,/; # skip lines ($bobinstance) = m/(bob(\d+))/; print ",\n" if not $first; $first = 0; $return = "\t{ \"{#BOBINSTANCE}\":\"$bobinstance\"}" u +nless /(^\s*$|^\,$)/; print $return; } } print "\t]\n"; print "}\n";
Thanks for the help.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2020-10-31 22:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (291 votes). Check out past polls.

    Notices?