use strict; use warnings; open my $fh, '<', 'hosts' or die; my @hosts = <$fh>; close $fh; my @new_hosts = grep { !/$ARGV[0]/ } @hosts; print "\nnew_hosts:\n"; print join "", @new_hosts; #### use strict; use warnings; open my $fh, '<', 'hosts' or die; my @hosts = <$fh>; close $fh; print "Excluding these lines:\n"; my @new_hosts = grep { print $_ if /$ARGV[0]/; !/$ARGV[0]/} @hosts; print "\nThe new array:\n"; print join "", @new_hosts;