Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Read from temp file

by Thelonius (Priest)
on Sep 03, 2008 at 21:44 UTC ( [id://708865]=note: print w/replies, xml ) Need Help??


in reply to Read from temp file

use File::Temp; use strict; my $fh = File::Temp->new(SUFFIX=>'.txt') or die "File::Temp: $!\n"; # $fh is a file handle. You can use it like this print $fh "This is a test\n"; # or as an object $fh->print("This is a only a test\n"); $fh->write("Testing 1,2,3\n"); # You can rewind and read it seek $fh, 0, 0 or die "Seek $fh failed: $!\n"; while (<$fh>) { print "Guess what I read: $_"; } # You can also use it as a filename to open it open ANOTHERFH, "<", $fh or die "Cannot open $fh: $!\n"; while (<ANOTHERFH>) { print "ANOTHERFH: $_"; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://708865]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2025-06-23 04:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.