in reply to how to open all file one by one
use strict; use warnings; my @txtfiles = glob "*.txt"; my @criticalfiles; for my $file (@txtfiles) { my $fh; if( not open $fh, "<", $file ) { print "Cannot open file $file, skipping.\n"; next; } while( <$fh> ) { if( /critical/ ) { push @criticalfiles, $file; last; } } close $fh; } print "Critical files:\n"; print join( "\n", @criticalfiles ), "\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how to open all file one by one
by GordonLim (Acolyte) on Apr 12, 2013 at 15:14 UTC | |
by ww (Archbishop) on Apr 12, 2013 at 15:44 UTC | |
by GordonLim (Acolyte) on Apr 12, 2013 at 16:10 UTC |