Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Please kindly explain this error message

by rovf (Priest)
on Sep 28, 2009 at 07:44 UTC ( #797845=perlquestion: print w/ replies, xml ) Need Help??
rovf has asked for the wisdom of the Perl Monks concerning the following question:

Recently I got the following error message, issued in one of the library modules I'm using:
Can't use an undefined value as a symbol reference
Could someone please explain to me what it means? If the error would be reproducible, I would put use diagnostics in this module, but so far the error has occured only once. The code in question looks like this:
print $fh $params{message} or die "Cannot write to '$self->{filename}': $!";
I wonder whether, by some chance, $fh got undef here, but then I would have expected to see something like can not write to undefined file handle. What is a 'symbol reference'? Is it that (deprectaed?) feature where you could use a string, denoting another variable, to indirectly refer to that variable?


-- 
Ronald Fischer <ynnor@mm.st>

Comment on Please kindly explain this error message
Select or Download Code
Re: Please kindly explain this error message
by Anonymous Monk on Sep 28, 2009 at 07:51 UTC
    echo Can't use an undefined value as a symbol reference at foo line 1. +|splain Can't use an undefined value as a symbol reference at foo line 1 (#1) (F) A value used as either a hard reference or a symbolic referenc +e must be a defined value. This helps to delurk some insidious errors.

      Thanks for telling about splain. Great tool!

      -- 
      Ronald Fischer <ynnor@mm.st>
Re: Please kindly explain this error message
by Anonymous Monk on Sep 28, 2009 at 07:53 UTC
    I think $fh is undef
    $ perl -Mdiagnostics -Mstrict -we ' my $fh = shift; print $fh 1' Can't use an undefined value as a symbol reference at -e line 1 (#1) (F) A value used as either a hard reference or a symbolic referenc +e must be a defined value. This helps to delurk some insidious errors. Uncaught exception from user code: Can't use an undefined value as a symbol reference at -e line +1. at -e line 1

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://797845]
Approved by broomduster
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2014-11-29 07:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (204 votes), past polls