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";
In reply to Re: how to open all file one by one
by hdb
in thread how to open all file one by one
by GordonLim
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |