Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: unable to eval dumped hash

by BillKSmith (Monsignor)
on Apr 28, 2020 at 14:48 UTC ( [id://11116163]=note: print w/replies, xml ) Need Help??


in reply to unable to eval dumped hash

You have already discovered that you need the EXPR (not BLOCK) form of eval. With this change, your original idea of removing $VAR1 works fine.
use strict; use warnings; use Data::Dumper qw(Dumper); my $hash; { local $/; $hash = <DATA>; } #$hash = eval { $hash }; $hash = eval $hash ; print keys %$hash; # error (no more) __DATA__ #$VAR1 = { { 'blah.com' => [ '212.235.56.176' ], 'blah.org' => [ '212.235.56.176' ], 'www.boo.org' => [ '212.235.56.176' ], };

OUTPUT:

C:\Users\Bill\forums\monks>perl 11116141.pl blah.comblah.orgwww.boo.org
Bill

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11116163]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-04-23 19:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found