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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading using a file handle

Status
Not open for further replies.

awingnut

Programmer
Feb 24, 2003
759
US
I have a function that returns a file handle. I am confused about how to read when an 'open' is not used. I understand reading this way:
Code:
open (FILEHANDLE,"myfile.txt");
my $line=<FILEHANDLE>;
In my case I have a function that returns a filehandle:
Code:
$pop->get($msgnum,my $fh);
my $line=<$fh>;
Obviously the above is wrong but I can't seem to find how to read it in the docs. Can someone help? TIA.
 
the function should be assigning and opening the file handle, what does the get function do?

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Thanks for the reply. That fucnction opens an email message using POP3 and retuns a file handle for the lines of the email. I need to read those lines. Since the file handle is a returned variable, I don't know how to reference it for read.
 
are you using Net::pOP3?

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Open the Filehandle for writing before calling the get function, and the contents of the message will be written to the filehandle.

You'll then have to reset the file pointer to start of file, before you can read what was written. You can do this using seek, but the quickest/cleanest way would be to close the file and reopen it for input as opposed to output

--Paul


Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top