in reply to uninitialized value in concatenation (.)
Taking these three things into account, I would rewrite the two lines which extract the filename as:
$filename =~ m/^.*(\\|\/)([^\\\/]*)$/; my $newfilename = $2 || die "Filename $filename failed to match!\n";
(Although in the real world, you'd probably want to attempt to recover gracefully from the failed match rather than dying...)
|
|---|