in reply to removing a column

It sounds like you only want to keep the first column of the /etc/hosts file. In that case, you can use the default behavior of split to split the lines on any whitespace, then just push the 1st element (column) into your array. Data::Dumper is just used for simple print-out:
use strict; use warnings; use Data::Dumper; my @ips; while (<DATA>) { next if /^#/; next if /^\s*$/; push @ips, (split)[0]; } print Dumper(\@ips); __DATA__ # comments: phony ip's 666.6.6.66 foo.bar 77.77.77.77 goo

prints:

$VAR1 = [ '666.6.6.66', '77.77.77.77' ];