my %file = ( in => 'switches.txt', ); @ARGV = $file{in}; chomp (@ARGV = <>); foreach my $nonsane (@ARGV) { chomp $nonsane; unless ($nonsane =~ (/^(\w|-|\.)+$/)) { print " Ack - $nonsane is an improperly formatted device name.\n"; print " Only alphanumeric, underscore, dash and dot allowed.\n"; exit; } } print (" Specified target names all valid.\n");