Skip to content

Instantly share code, notes, and snippets.

@larsks
Last active December 13, 2015 22:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save larsks/4986776 to your computer and use it in GitHub Desktop.
Save larsks/4986776 to your computer and use it in GitHub Desktop.
use strict;
use warnings;
sub demo {
my $Data;
eval { $Data = { lars => 'nifty' }; };
print $Data->{lars}, "\n";
}
demo;
@SEJeff
Copy link

SEJeff commented Feb 19, 2013

This is what I was using, but it seems to work fine:

#!/usr/bin/env perl
use JSON;
use strict;
use diagnostics;

my $JSONObject = JSON->new->allow_nonref;
my $jsonstr = '{"one":1,"two":2,"three":3}';
my $Data;
eval { $Data = $JSONObject->decode($jsonstr); };
print $Data->{'one'} . "\n";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment