JackPerl has asked for the wisdom of the Perl Monks concerning the following question:
For example I get errors like this when trying to access just the 'meta' fields..
Can't use string ("{"meta":{"status":200,"msg":"OK"") as an ARRAY ref while "strict refs" in use
What I really need is to get all the fields from the 'response' bit which presumably requires looping on something. Any help to resolve this would be gratefully received, before I lose what is left of my sanity.. ;)
$VAR1 = '{"meta":{"status":200,"msg":"OK"},"response":[{"blog_name":"w +mr101","id":69895404084,"post_url":"http:\\/\\/wmr101.tumblr.com\\/po +st\\/69895404084\\/while-read-stdin-2048-a-29-b-73-c-142-t","slug":"w +hile-read-stdin-2048-a-29-b-73-c-142-t","type":"quote","date":"2013-1 +2-13 18:18:57 GMT","timestamp":1386958737,"state":"published","format +":"html","reblog_key":"KEalDhb2","tags": ["perl"],"short_url":"http:\\/\\/tmblr.co\\/ZQJ0Ox1165peq","highlighte +d":[],"note_count":0,"text":"$_=’while(read+STDIN,$_,2048){$a=29;$b=7 +3;$c=142;$t=255;@t=map{$_%16or$t^=$c^=($m=(11,10,116,100,11,122,20,10 +0)[$_\\/16%8])&110;$t^=(72,@z=(64,72,$a^=12*($_%16-2?0:$m&17)),$b^=$_ +%64?12:0,@z)[$_%8]}(16..271);if((@a=unx”C*”,$_)[20]&48){$h==5;$_==unx +b24,join”“,@b=map{xB8,unxb8,chr($_^$a[—$h+84])}@ARGV;s\\/…$\\/1$&\\/; +$d=unxV,xb25,$_;$e=256|(ord$b[4])>8^($f=$t&($d»12^$d»4^$d^$d\\/8))>8^ +($t&($g=($q=$e»14&7^$e)^$q*8^$q>=8)+=$f+(~$g&$t))for@a[128..$#a]}prin +t+x”C*”,@a}’;s\\/x\\/pack+\\/g;eval","source":""}, {"blog_name":"a0001","id":69691252013,"post_url":"http:\\/\\/a0001.tum +blr.com\\/post\\/69691252013\\/perl","slug":"perl","type":"text","dat +e":"2013-12-11 14:48:03 GMT","timestamp":1386773283,"state":"publishe +d","format":"html","reblog_key":"Lhh9Osdt","tags":["perl"],"short_url +":"http:\\/\\/tmblr.co\\/ZSfAvp10vx1qj","highlighted":[],"note_count" +:0,"title":"perl\\u3067\\u30d5\\u30a1\\u30a4\\u30eb\\u3092\\u8aad\\u3 +07f\\u8fbc\\u3080","body":"\\u003Cp\\u003E\\u30d5\\u30a1\\u30a4\\u30e +b\\u30aa\\u30fc\\u30d7\\u30f3\\u3001\\u3088\\u304f\\u4f7f\\u3046\\u30 +6e\\u3067\\u66f8\\u3044\\u3066\\u307f\\u307e\\u3057\\u305f\\u3002\\u0 +03C\\/p\\u003E\\n\\u003Cpre class=\\u0022brush:perl;\\u0022\\u003E op +en $FH, \\u0022hoge.txt\\u0022 or die $!;\\n while ( readline $FH ) { +\\n # \\u51e6\\u7406 \\n }\\n clise $FH;\\n\\u003C\\/pre\\u003E\\n\\u +003Cp\\u003Eor\\u6f14\\u7b97\\u5b50\\u306f\\u5de6\\u8fba\\u3092\\u8a5 +5\\u4fa1\\u3057\\u3066\\u3002\\u7d50\\u679c\\u304c\\u507d\\u306e\\u58 +34\\u5408\\u306f\\u003C\\/p\\u003E\\n\\u003Cp\\u003E\\u53f3\\u8fba\\u +3092\\u5b9f\\u884c\\u3057\\u307e\\u3059\\u3002\\u3053\\u306e\\u5834\\ +u5408\\u306f\\u30d5\\u30a1\\u30a4\\u30eb\\u30aa\\u30fc\\u30d7\\u30f3\ +\u304c\\u5931\\u6557\\u3059\\u308b\\u3068\\u003C\\/p\\u003E\\n\\u003C +p\\u003Eundef\\u304c\\u8fd4\\u308a\\u3001undef\\u306ffalse\\uff08\\u5 +07d\\uff09\\u6271\\u3044\\u306a\\u306e\\u3067\\u003C\\/p\\u003E\\n\\u +003Cp\\u003Edie\\u95a2\\u6570\\u3092\\u5b9f\\u884c\\u3057\\u3066\\u30 +d7\\u30ed\\u30b0\\u30e9\\u30e0\\u304c\\u7d42\\u4e86\\u3057\\u307e\\u3 +059\\u3002\\u003C\\/p\\u003E\\n\\u003Cp\\u003E\\u305d\\u306e\\u3068\\ +u304d$!\\uff1d\\u30a8\\u30e9\\u30fc\\u30e1\\u30c3\\u30bb\\u30fc\\u30b +8\\u304c\\u6a19\\u6e96\\u51fa\\u529b\\u306b\\u8868\\u793a\\u3055\\u30 +8c\\u307e\\u3059\\u3002\\u003C\\/p\\u003E\\n\\u003Cp\\u003E\\u3081\\u +3067\\u305f\\u304f\\u6210\\u529f\\u3057\\u305f\\u3068\\u304d\\u306fwh +ile( readline $FH )\\u306b\\u9032\\u307f\\u307e\\u3059\\u3002\\u003C\\/p\\u003E\\n\\u00 +3Cp\\u003Ereadline\\u3067\\u30d5\\u30a1\\u30a4\\u30eb\\u306e\\u5185\\ +u5bb9\\u3092\\u4e00\\u884c\\u305a\\u3064\\u53d6\\u5f97\\u3057\\u3066\ +\u003C\\/p\\u003E\\n\\u003Cp\\u003E\\u4f55\\u304b\\u3057\\u3089\\u51e +6\\u7406\\u3067\\u304d\\u307e\\u3059\\u3002\\u53d6\\u5f97\\u3057\\u30 +5f\\u5185\\u5bb9\\u306f$_\\u306b\\u5165\\u3063\\u3066\\u307e\\u3059\\ +u30fc\\u3002\\u003C\\/p\\u003E\\n\\u003Cp\\u003E\\u003Ca href=\\u0022 +http:\\/\\/www.perlplus.jp\\/perl\\/file\\/index3.html\\u0022 target= +\\u0022_blank\\u0022\\u003Ehttp:\\/\\/www.perlplus.jp\\/perl\\/file\\ +/index3.html\\u003C\\/a\\u003E\\u003C\\/p\\u003E"}, etc.
Thanks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Extracting data from api response..
by choroba (Cardinal) on Dec 14, 2013 at 19:32 UTC | |
|
Re: Extracting data from api response..
by roboticus (Chancellor) on Dec 14, 2013 at 23:51 UTC | |
by JackPerl (Initiate) on Dec 16, 2013 at 20:41 UTC | |
|
Re: Extracting data from api response..
by Anonymous Monk on Dec 15, 2013 at 06:40 UTC | |
by JackPerl (Initiate) on Dec 15, 2013 at 17:22 UTC |