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 () { # Grab all strings that contain this regex if (/$re/) { # Save them all in $out print OUT $1; } }