I am attempting to use the File::Temp libraries to read and write to
auto generated files but I am having trouble reading from the file
after the data has been written. I believe this to be something
specific to how tempfile() works because I have been able to
successfully read from a scalar handle the old fashioned way.

open $filHandle, "file.txt";

however,

#==========Hello World
use strict;

use File::Temp ('tempfile');

my $tempFile;
my $fileName;
($tempFile, $fileName) = tempfile();

if (defined $tempFile){ print $fileName . "\n"; }

print $tempFile "Hello World!\n";

if (defined $tempFile){ print "debug\n"; }

print $tempFile->getline; #line 15

#below code results in the same error
#my $rd = <$tempFile>;
#print $rd;

exit;

produces the following output and error

/tmp/JVdETHxVFM
debug
Use of uninitialized value in print at hw.pl line 15.

I am able to open the temp file and verify that "Hello World!" has
been written and I have checked the permissions of the dir to verify I
have read/write. I'm stumped, this seems straight forward enough. Is
there something specific I must do to switch from write mode to read
mode?

Thanks


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to