in reply to Re: Re: perl Regex
in thread perl Regex

Perhaps I should have been more clear in my original comment when I said you could split on "DOMAIN\|".

use strict; use warnings; my @domain_names; open ("FILE", "< ./file.csv") or die ("Can't open file $!"); while (my $line = <FILE>) { 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; }

And, of course, if you only have one DOMAIN|test.com in every file you could add an if to check if there's one on the current line using a regular expression, and then a last to exit the loop once you found one.


Want to support the EFF and FSF by buying cool stuff? Click here.