the following sample of 60mb json file:
[ { "phish_id":"3332444", "url":"http://shydroservice.ru/plugins/content/fboxbot/standardbank3/inet.php", "phish_detail_url":"http://www.phishtank.com/phish_detail.php?phish_id=3332444", "submission_time":"2015-07-17t09:58:13+00:00", "verified":"yes", "verification_time":"2015-07-17t10:14:15+00:00", "online":"yes", "details":[ { "ip_address":"37.140.192.240", "cidr_block":"37.140.192.0/24", "announcing_network":"197695", "rir":"ripencc", "country":"ru", "detail_time":"2015-07-17t09:59:28+00:00" } ], "target":"other" }, ... ] i ip_address of details, code doesn't find details array :'(
use strict; use warnings fatal => 'all'; use lwp::simple qw(get); use json qw(decode_json); $url = "http://127.0.0.1/test.json"; $decoded = decode_json(get($url)); foreach $f ( @decoded ) { print $f->{"details"} . "\n"; } i have message:
not hash reference @ ./get_article.pl line 15. can me? thanks.
at top level, have [], $decoded reference array.
for $f (@$decoded) { ... } inside have {}, $f reference hash.
$details = $f->{details}; inside have [], $details reference array.
$detail (@$details) { ... } inside have {}, $detail reference hash.
$ip_address = $detail->{ip_address}; all together:
for $f (@$decoded) { $details = $f->{details}; $detail (@$details) { $ip_address = $detail->{ip_address}; ... } }
Comments
Post a Comment