http://www.perlmonks.org?node_id=1218391


in reply to Re: Best way to compare range of characters in two text files
in thread Best way to compare range of characters in two text files

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^3: Best way to compare range of characters in two text files
by AnomalousMonk (Archbishop) on Jul 12, 2018 at 17:26 UTC

    Somebody needs to scramble for  perldoc -f read because

    read FILEHANDLE,SCALAR,LENGTH,OFFSET
    ... Returns the number of characters actually read, 0 at end of file, or undef if there was an error (in the latter case $! is also set). ... [emphases added]

    In this particular case, you're probably not going to be sitting at the end of the file just after opening it (unless the file's empty) and only one read is ever done, but a statement like
        read($fh1, my $rec1, $length, $offset) or die("Can't read $file1");
    will die at the end of the file, and that's not proper handling of an error condition. (It would have been nice to have had  $! in the die message, too. Some study of the purpose of the OFFSET parameter might also be profitable.)


    Give a man a fish:  <%-{-{-{-<

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re^3: Best way to compare range of characters in two text files
by Anonymous Monk on Jul 12, 2018 at 17:26 UTC

    Just because it's possible to write Pascal in Perl doesn't mean it's advisable.

    A reply falls below the community's threshold of quality. You may see it by logging in.