Perl-Sensitive Sunglasses | |
PerlMonks |
Re: Reading input byte by byteby leira (Monk) |
on Apr 17, 2004 at 02:50 UTC ( [id://345928]=note: print w/replies, xml ) | Need Help?? |
For some reason, it reads and prints the entire thing even though I only tell it to print 1 byte!
Actually, you're telling it to read one byte at at time, until there's nothing left (read returns the number of bytes it succeeded in reading -- when there are none left, it will return 0, and your while loop will stop):
...and then you're appending what you read during this pass onto what you've already read, until $text contains everything in the file:
....and then you're printing out the whole thing:
If you only want to read 1 byte and then stop, you probably don't want to put it in a while loop. Linda
In Section
Seekers of Perl Wisdom
|
|