Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What does IO::File=GLOB mean?

Status
Not open for further replies.

ITadvice

IS-IT--Management
Jul 22, 2008
38
US
I put some information in a temp file but when I try to print what’s in the file, I get this instead--> IO::File=GLOB(0x8791…). What does this mean? Is the data not being written into the temp file? Here is a portion of my code.


foreach $line (@data) {
chomp $line;

($timestamp, $dump1, $dump2, $out, $dump3, $dump4, $dump5, $in, $dump6)=split(/\t/, $line); # Sort out needed columns

foreach ($line) { # Format time/date
my $datetime = DateTime::Format::Excel->parse_datetime($timestamp);
$timestamp = $datetime->ymd . $datetime->hms;
seek ($fh, 0, 0) or die "Seek: $!";
print $fh "$timestamp $out $in\t";
}
print $fh;
}
close (FILE);


 
your not printing what is in the file.. you are printing the filehandle itself

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
Further up in my code I have the following line:
Code:
my $fh = IO::File->new_tmpfile or die "Unable to make new temp file: $!";

Does this put the contents of the file in $fh or is it just pointing to the file? Because this is a randomly generated file, I want to be able to access the file using a variable since I don't know the name of the temp file.
 
The code above creates the filehandle $fh, $fh is a pointer to the file, it is not the file itself. Are you sure you want to use the new_tmeplfile method?

new_tmpfile

Creates an IO::File opened for read/write on a newly created temporary file. On systems where this is possible, the temporary file is anonymous (i.e. it is unlinked after creation, but held open). If the temporary file cannot be created or opened, the IO::File object is destroyed. Otherwise, it is returned to the caller.


------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top