my $jsonc = read_file ('H:\Work\perl\latest\Scripts\logs\json.txt');
local $/ = "}";
while ($jsonc) {
s/\n[+]?//gm;
my $data = decode_json $jsonc;
for (@{$data->{aaData}}) {
#my print function
}
####
my $jsonc = read_file ('H:\Work\perl\latest\Scripts\logs\json.txt');
{
local $/ = "}\n";
while ($jsonc) {
s/\n[+]?//gm;
my $data = decode_json $_;
for (@{$data->{aaData}}) {
#my print/parse function
}
}
}
####
#!/usr/bin/env perl -l
use strict;
use warnings;
use JSON;
use Time::Piece;
my $json_file = 'json.txt';
my $wanted_minute = 40;
open my $json_fh, '<', $json_file or die "Can't read '$json_file': $!";
{
local $/ = "}\n";
while (<$json_fh>) {
s/\n[+]?//gm;
my $data = decode_json $_;
for (@{$data->{aaData}}) {
print "@$_" if is_wanted_time(@$_[0,1]);
}
}
}
close $json_fh;
sub is_wanted_time {
for (@_) {
my $t = gmtime $_;
return 1 if $t->min == $wanted_minute;
}
return 0;
}
####
$ cat json.txt
{"DisplayRecords":"12","Records":"12","sColumns":"startTime,endTime,
remoteNode,srcIP,srcPort,destIP,destPort,egress,ingress","aaData":[["1
+375976271"
,"1375976430","LAN","D0:05:FE","172.20.30.2",1093,"172.20.28.2",1330,"
+1034,348"]]}
{"DisplayRecords":"12","Records":"12","sColumns":"startTime,endTime,
remoteNode,srcIP,srcPort,destIP,destPort,egress,ingress","aaData":[["1
+375976271"
,"1375976430","LAN","D0:05:FE","172.20.30.2",1093,"172.20.28.2",1330,"
+1034,348"]]}
####
$ pm_epoch_from_json_3.pl
1375976271 1375976430 LAN D0:05:FE 172.20.30.2 1093 172.20.28.2 1330 1034,348
1375976271 1375976430 LAN D0:05:FE 172.20.30.2 1093 172.20.28.2 1330 1034,348