$ENV{'PATH'} = 'home/username/www/xmpx/'; delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'}; ... sub uploader { my $sourcefile = $query->param('uploadthis'); $sourcefile =~ /([\w .-]+)$/i; #strip off path my $newfile = $1; open (OUTFILE, ">../$branch/images/$newfile") or die "Cannot open $newfile: $!"; ... }