I tried to implement some advice about slurping that I read on this mailing
list (using local) but cannot get it to work. I get the message “Value of
<HANDLE> construct can be "0"; test with defined() at line 23” (the $slurp =
<$fh1> line). I’m using perl version 5.18.2 installed in 2014.
I’ve googled this error and think (ha!) I understand it, but though I’ve tried
many changes, I cannot make the error go away. I need the advice of folks who
are way ahead of me!
Rick Triplett
use warnings;
use strict;
use DB_File; # module for Berkeley DBM w/ DB_HASH file type
use CGI::Carp qw ( fatalsToBrowser );
# Declare some globals
my $server = 'exploringmyself';
my $file_to_convert = 'Untitled.tab';
chdir "/big/dom/x$server/data/courses/"
or die "Can't chdir to /courses: $!\n";
if (! -e "$file_to_convert") {
die "Can't find $file_to_convert: $!\n"
};
my $slurp;
{
local $/;
open my $fh1, '<', $file_to_convert
or die "Can't open $file_to_convert: $!\n";
$slurp = <$fh1>
or die "Could not slurp $file_to_convert: $!";
$slurp =~ s/\r/\n/xmsg; # swap Mac's CR for LF
$slurp =~ s/\x0b/<br>/xmsg; # swap Filemaker paragraph marker VT for html
close $fh1;
}