use strict; use warnings; my @domain_names; open ("FILE", "< ./file.csv") or die ("Can't open file $!"); while (my $line = ) { my @parts = split 'DOMAIN\|', $line; # throw away the stuff before DOMAIN| shift (@parts); # now get what's between the beginning # of the line and the | -- the domain, correct? my $part = shift (@parts); @parts = split '\|', $part; my $domain = shift (@parts); push @domain_names, $domain; }