How would I solve the following error:
readline() on unopened filehandle UPPER at faStat2 line 86.
in the following code?
#!/usr/bin/perl
use strict;
use warnings;
...
my $cmd = $0;
$cmd =~ s#.*/##;
($#ARGV > 0) || die "Usage $cmd <tibcoUpperMDLog> <tibcoLowerMDLog> <outFile>\n\n";
open(my $UPPER, $ARGV[0]) || die "Unable to open $ARGV[0]\n";
open(my $LOWER, $ARGV[1]) || die "Unable to open $ARGV[1]\n";
...
while ($msg = <UPPER>) { getUpperBusTimeStampAndBatchSize(\$msg); } #This is the line that the error is complaning about
Here I include both practical and stylistic chages.
Practical:
open(safer, modern)Stylistic:
orrather than braces and||(least important)@ARGVrather than$#ARGV(more readable, “need at least 2 args”)my) variables