in reply to Insecure dependency error and $ENV{'PATH'}

If $sourcefile =~ /.../ does not match then $1 will contain whatever the last successful match captured. This is a bug in your program. You must test the result of the match for success and only then use $1 otherwise bail or use a sane default.

my $newfile = ( $sourcefile =~ /...(...).../i ? $1 : 'somedefault' );