我希望在其自己的数组中读取使用 ARGV 指定的每个(小)文件。如果我不测试$ARGV
,<>
将把所有文件都放在一个表中。有更好/更短/更简单的方法吗?
# invocation: ./prog.pl *.txt
@table = ();
$current = "";
while (<>)
{
if ($ARGV ne $current)
{
@ar = ();
$current = $ARGV;
if ($current)
{
push @table, \@ar;
}
}
push @ar;
}