my $filename = take_user_input(); $filename =~ s/\W//g; # allows only alphanumerics and the underscore $filename = $filename . ".txt"; # forces them to only open .txt files if (-T $filename) # checks to see if the file is a text file { open IN, "<", $filename or die &cant_open_file; print join "", <IN>; close IN; } else { &cant_open_file; }
In reply to Re: escaping filenames taken in via user input
by stupidius
in thread escaping filenames taken in via user input
by revdiablo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |