open (CFGFILE, "ship.cfg") || die $!; while (my @TMP=) { next if ( /#/ ); # Lets untaint the data after making sure it only matches # word characters... For more info read perldoc perlsec. foreach $_(@TMP) { if ($_ =~ /^([\w.]+)$/) { $_ = $1; push (@hosts, $1); } else { next; } } } #### open CFGFILE, "< ship.cfg" or die "read ship.cfg: $!"; @hosts = map { /^([\w.]+)$/ ? $1 : () } grep !/#/, ; } close CFGFILE; #### open CFGFILE, "< ship.cfg" or die "read ship.cfg: $!"; while () { /#/ and next; /^([\w.]+)$/ or next; push @hosts, $1; } close CFGFILE;