if (my ($dt, $msg, $source, $destination) = $text =~ /([0-9]{4}-[0-9]{2}-[0-9]{2}[ ][0-9]{2}:[0-9]{2}:[0-9]{2}) [ ]FATAL:[ ]Error[ ]while[ ]copying[ ] (.+) [ ]from[ ] (.+) [ ]to[ ] (.+), /x ) { ( my $source_without_drive = $source ) =~ s/^\w://; my $sourcebis = '\\\\ENCNRW0010' . $source_without_drive; File::Copy::copy $source.$msg, $destination; push @mail, "$dt $msg from $sourcebis to $destination\n"; $text =~ s/FATAL: Error while copying /FATAL (Fixed): Error while copying /g; push @text, $text."\n"; } }