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
In reply to Re: script to grab string from log and print them in a different log
by davorg
in thread script to grab string from log and print them in a different log
by perl_geoff
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |