Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Data::Dumper and eval

by chromatic (Archbishop)
on Nov 28, 2000 at 05:40 UTC ( [id://43588]=note: print w/replies, xml ) Need Help??


in reply to Data::Dumper and eval

If there's a possibility that your file is empty, you need an extra step:
open DATA, "<$datafile" or die "$!"; my $dumped_hash; { local $/; $dumped_hash = <DATA>; } my %somehash; %somehash = %{ eval $dumped_hash } if $dumped_hash;
That way, %somehash is empty and you'll avoid those errors if there's nothing in the file.

Update: jcwren pointed out that I had an extra line that should have been edited out. I dare you to find it now.

Log In?
Username:
Password:

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

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

    No recent polls found