#!/usr/bin/perl use strict; use warnings; my @hosts; while(<>){ chomp; die "usage: do_something [file]\n" if $ARGV eq '-' and ! $_; next unless $_; push @hosts, $_; } print "Read hosts:\n"; print $_,$/ for @hosts;