我將如何解決以下錯誤:我如何解決以下錯誤「readline()在faStat2第86行的未打開的文件句柄UPPER上。」?
readline() on unopened filehandle UPPER at faStat2 line 86.
在下面的代碼
?
#!/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
裸字的文件句柄是一個古老的功能。對於現代代碼,你應該使用詞法文件句柄(比如'$ UPPER'而不是'UPPER')。你還應該使用3參數版本的'open'。請參閱[本文](http://www.modernperlbooks.com/mt/2010/04/three-arg-open-migrating-to-modern-perl.html)。 – 2012-01-05 20:43:27