born_Today has asked for the wisdom of the Perl Monks concerning the following question:
Monks help needed
i am new to perl..i got a output file which contains two different strings. if my search matches string1, just print that line and if my search matches string2 , count the occurances and print the count
i tried the below but it is not printing count
#!/usr/bin/perl my %count; @files = <C:/temp/CHOP/*JUNE*>; foreach $file (@files) { open (FILE,"$file"); print "=====$file=====\n"; while($line= <FILE>) { print "$line" if $line =~ /Total/; } while ($failed= <FILE> ) { if (failed =~ /failed/) { $count{$failed)++; } } close FILE; print "Total Volume Failed to Resolve:$count{$failed} \n" ; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Process multiple files in a directory
by Athanasius (Archbishop) on Jun 27, 2015 at 16:26 UTC | |
|
Re: Process multiple files in a directory
by aaron_baugher (Curate) on Jun 27, 2015 at 17:51 UTC | |
by kcott (Archbishop) on Jun 28, 2015 at 01:21 UTC | |
by aaron_baugher (Curate) on Jun 28, 2015 at 01:39 UTC | |
|
Re: Process multiple files in a directory
by stevieb (Canon) on Jun 27, 2015 at 16:56 UTC |