develooper Front page | perl.beginners | Postings from March 2002

Re: Transfer a file via FTP

Thread Previous
Jenda Krynicky
March 29, 2002 08:21
Re: Transfer a file via FTP
Message ID:
From:           	Ahmed Moustafa <>
> Jenda Krynicky wrote:
> > Anyway when reading file you don't need any end of line character,
> > the system KNOWs how long is the file at the moment and <FILEHANDLE>
> > will return undef if you've read all there is.
> I didn't get what you meant by "<FILEHANDLE> will return undef if
> you've read all there is"; would you explain more, please?

if you open a file and the read it line by line by

	$line = <FILEHANDLE>;

then as soon as you have read all lines in the file, the $line will get 
set to undefined. That is if you want to read and process all lines in 
a file you do this:

	open FILEHANDLE, "< $filename"
		or die "Cannot open $filename : $!\n";

	while (defined ($line = <FILEHANDLE>)) {
		do whatever you like with $line
	# now we've read "all there is" = "all data in the file"

The file doesn't have to end with any special character, and most 
likely will not.


=========== == ==========
There is a reason for living. There must be. I've seen it somewhere.
It's just that in the mess on my table ... and in my brain
I can't find it.
					--- me

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About