My perl script takes any number of files, opens them, and reads one line from each. But it\'s not working. Here\'s my code.
#!/bin/perl
$numfile = scalar @ARGV
[Not an answer, but a comment that doesn't fit as a comment]
Always use use strict; use warnings;
. You are severely handicapping yourself without them.
You don't need to use multiple handles since you never need more than one at a time.
Some other cleanups:
#!/bin/perl
use strict;
use warnings;
my @first_lines;
for my $qfn (@ARGV)
{
open(my $fh, '<', $qfn)
or die("Can't open $qfn: $!\n");
push @first_lines, scalar( <$fh> );
}
for my $i (0..$#first_lines)
{
print "$i => $first_lines[$i]";
}