my $file = "//Administrator/Web Sites/Learning/myweek_$no.html"; if ($file =~ /^([-\@\w._:\/]+)$/) { $file = $1; # $data now untainted } else { print "Please report this error to the admin. Thanks"; exit; } open OUTPUT, ">$file.html"; print OUTPUT $template->output; close OUTPUT;