use URI::Escape; my $escaped_file = uri_escape($nfile);