in reply to removing a column

I may be misunderstanding what you're asking, but to get only 1 column, you can just split the line as you read it.

open(HOSTFILE,"<$hostfile"); foreach (<HOSTFILE>){ if($_ =~ m/^#/){next;} if($_ =~ m/^\s$/){next;} # Insert this line to split by whitespace my @lineParts = split (/\s+/, $_); # push (@hostcontents,$_); # Push [0] first column (ip), or use [1] for second column (hostname) push (@hostcontents,$lineParts[0]); } close(HOSTFILE);