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 "", ; close IN; } else { &cant_open_file; }