You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I/O operations like open or <> are not automatically checked for errors in Perl (compare Python, where exceptions are thrown). Instead for instance the <FH> operator returns undef if the file's end is reached or if there is an error on the stream (e.g. broken pipe).
Consequently, all usages of such function/operators in Perl need to explicitly guarded to ensure no I/O error happened.
This error can result in undetected partial processing of inputs files, in particular in less stable runtime environments and with a probability approach one when scaling out.
In the code it seems open is usually guarded (or die), but the <FH> operator is almost never guarded. Also read or write operations need to be guarded and possibly (unsure) also print FH ... should be guarded.
An example of correct(er) error handling:
my$line = readline(STDIN)
|| die"Couldn't read header from standard input: $!";
while (! eof(STDIN)) {
my$line = readline(STDIN);
if (! defined$line) {
die"Couldn't read from standard input: $!";
}
doSomethingWith($line);
}
Command used and terminal output
None. Problem occurs sporadically.
Relevant files
Probably all Perl scripts lib/*.pl. All should be checked.
System information
This is valid for all versions of Perl and independent of all the other possible system information.
The text was updated successfully, but these errors were encountered:
Have you checked the docs?
Description of the bug
I/O operations like
open
or<>
are not automatically checked for errors in Perl (compare Python, where exceptions are thrown). Instead for instance the<FH>
operator returnsundef
if the file's end is reached or if there is an error on the stream (e.g. broken pipe).Consequently, all usages of such function/operators in Perl need to explicitly guarded to ensure no I/O error happened.
This error can result in undetected partial processing of inputs files, in particular in less stable runtime environments and with a probability approach one when scaling out.
In the code it seems
open
is usually guarded (or die
), but the<FH>
operator is almost never guarded. Alsoread
orwrite
operations need to be guarded and possibly (unsure) alsoprint FH ...
should be guarded.An example of correct(er) error handling:
Command used and terminal output
None. Problem occurs sporadically.
Relevant files
Probably all Perl scripts
lib/*.pl
. All should be checked.System information
This is valid for all versions of Perl and independent of all the other possible system information.
The text was updated successfully, but these errors were encountered: