in reply to Re^4: Perl: Directoriesand files
in thread Perl: Directoriesand files

Yes there is:

my @content; foreach ('','.1','.2','.3','.4') { open(my $fh,'<',$string.$_) or die "Could not open $string.$_ : $!\n +"; push @content, scalar <$fh>; } if ($content[0] == $x){ print @content; $x++; }

UPDATE: removed bug. UPDATE2: removed another bug found by anon monk

Replies are listed 'Best First'.
Re^6: Perl: Directoriesand files
by Anonymous Monk on Mar 30, 2011 at 11:35 UTC
    Context matters :) use
    scalar <$fh>; scalar readline $fh;
    to read a SINGLE line from each file