#!/usr/bin/perl use strict; use warnings; use feature 'say'; say "Enter the name of the file to read: "; my $filetoread = ; chomp($filetoread); say "Enter the name of the file to write: "; my $filetowrite = ; chomp($filetowrite); open my $readhandle, "<", $filetoread or die "Unable to read '$filetoread': $!"; open my $writehandle, ">>", $filetowrite or die "Unable to write '$filetowrite':$!"; while (<$readhandle>){ chomp; if (m/^Name=(\S+)/) { say $writehandle $1; } if (m/^Path=(\S+)/) { say $writehandle $1; } } close $readhandle or warn "Unable to close ".$filetoread.": $!"; close $writehandle or warn "Unable to close ".$filetowrite.": $!"; __END__ $ cat out.txt blocka /main/sub/a/bg/adee/swarfrw/ewqsx/fewaxr/akeil/awedr/date/file