Rob Dixon wrote:
John W. Krahn wrote:

In perl you almost *never* need to use the eof() function. That is usually written as:

while ( read IN, $buffer, $blksize )
    {

But even that doesn't report any errors that read() may encounter.

while ( my $read = read IN, $buffer, $blksize )
    {
    defined $read or die "Cannot read from '$infile' $!";

If $read is undefined then while test will already have failed.

my $read;
while ( $read = read IN, $buffer, $blksize ) {
 :
}

defined $read or die "Read from '$infile' failed: $!";

Thanks Rob.  Sorry for the mistake.  :-)



John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to