in reply to Send JSON data to Perl scalar

I think what you're looking for is...

use LWP::Simple qw(get); use JSON qw(from_json); my $username = 'ESPN'; my $data = from_json get "http://twitter.com/users/${username}.json"; print $username, " has ", $data->{followers_count}, " followers.\n";
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Replies are listed 'Best First'.
Re^2: Send JSON data to Perl scalar
by perl.j (Pilgrim) on Dec 21, 2012 at 17:35 UTC

    This is great! My only issue here is speed, since this is going to be run about once every minute or two.

    --perl.j

      I don't see why that would be a problem. That script takes about 1.2 seconds to execute on my laptop (and this machine is pretty old and underpowered), so could comfortably execute 30 or 40 times per minute.

      Though probably if I wanted to retrieve this data more than once a minute, I'd probably just add a loop to the script so that you execute it once and it runs in the background, repeatedly retrieving the data.

      perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'