# check to see if you have a command line argument my $file = $ARGV[0]; # if not, or if it's not an HTML file, then prompt for one until ($file && ($file =~ /\.html?$/i)) { print('Enter an html file (with either a .html or .htm extension): '); $file=; chomp $file; }