use strict; use warnings; my $returncode; $returncode = 0; open (my $IN,"<c:/temp/logbook.log") || die "can not open datei: $!"; while(<$IN>){ if( /error/i ){ print; $returncode++; print "$returncode\n"; } } if ( $returncode == 0 ){ my $file = '/temp/ok.txt'; open FILE, '>', $file or die "Kann Datei $file nicht zum Schreiben +oeffnen: $!\n"; print FILE "ok!\n"; close FILE; } close $IN;
Thanks
MH
In reply to Re^2: Write a file if grep finds a pattern?
by matze77
in thread Write a file if grep finds a pattern?
by matze77
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |