[sf-perl] Can't use an undefined value as filehandle reference
greg lee coleman [1482]
gregc at cnet.com
Wed Jul 6 13:22:34 PDT 2005
# this has worked for me in the past:
my %fh = ();
if (-f $file and ! $fh{$file} ) {
open($fh{$file}, "<$file") || DisplayError();
# coolness ensues...
}
# be sure to close' those FH on the way out...
-gleeco
________________________________________________________________
On Wed, 6 Jul 2005, Vicki Brown wrote:
> I am trying to run tmail.pl
> http://pugetsoundsoftware.com/tmail.html
> for The Job. The Company still runs Perl 5.005_03. (Don't get me started).
>
> I get an error running the script:
> Can't use an undefined value as filehandle reference at tmail.pl line 149.
>
> No error with newer Perl (5.8.5 on my desktop).
>
> Here's the relevant code. The error is on line 5 in the example.
>
> #!/usr/bin/perl
>
> $szForm = "/www/private/nonexistent.txt";
>
> DisplayError ("tmail: template form [$szForm] could not be opened")
> if (!open ($file, "<$szForm")); # This line faults
>
> sub DisplayError {
> print @_, "\n";
> }
>
>
> Perl 5.8.5 runs successfully and prints
> tmail: template form [/www/private/nonexistent.txt] could not be opened
>
> Perl 5.00503 shows
> Can't use an undefined value as filehandle reference at foo.pl line 5
>
>
> How can I work around the problem?
>
> Please don't suggest that I try to convince IT to upgrade Perl. :-(
> That's not going to happen.
>
> My other choice is to use a phenomenally ugly hunk of PHP code.
> So if you can save me from that... Heeeeeeeeelllllllpppp!
>
> --
> - Vicki
>
> ZZZ
> zzZ San Francisco Bay Area, CA
> z |\ _,,,---,,_ Books, Cats, Tech
> zz /,`.-'`' -. ;-;;,_ http://cfcl.com/vlb
> |,4- ) )-,_. ,\ ( `'-' http://cfcl.com/vlb/weblog
> '---''(_/--' `-'\_) http://heatercats.com
> _______________________________________________
> SanFrancisco-pm mailing list
> SanFrancisco-pm at pm.org
> http://mail.pm.org/mailman/listinfo/sanfrancisco-pm
>
More information about the SanFrancisco-pm
mailing list