in reply to Unable to read a file

I assume this is the culprit:

">$dest_dir./result.txt"

What is that dot doing in there?

But yes, you should always check the success of open and handle failures (usually with something like or die "cannot open '$filename': $!").

Or use autodie.

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'