in reply to script to grab string from log and print them in a different log
use strict; use warnings; my $out = "Backup/backup.txt"; my $logfile="log.txt"; # Single quotes for more aethestically pleasing strings my $MAL = '"_'; my $endstring = '"'; # Build a regular expression my $re = qr[($MAL.*?$endstring)]; open LOG, "<", $logfile or die "Cannot open $logfile for read :$!"; open OUT, ">", $out" or die "Cannot open $out for write :$!"; while (<LOG>) { # Grab all strings that contain this regex if (/$re/) { # Save them all in $out print OUT $1; } }
"The first rule of Perl club is you do not talk about Perl club." -- Chip Salzenberg
|
|---|