Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^3: Best way to compare range of characters in two text files

by AnomalousMonk (Archbishop)
on Jul 12, 2018 at 17:26 UTC ( [id://1218394]=note: print w/replies, xml ) Need Help??


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

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:  <%-{-{-{-<

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1218394]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-04-23 06:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found