in reply to Parsing a 3-Column Tab-Deliminated File
Hmm, well I'll give it a go... you say tab seperated, but it's hard to know from the sample whether these have been transformed to spaces or not, so the following should work in either case.
Personally, although an elegant idea, I wouldn't use a hash here (it would dump you in the deep end with regard to references, etc.).
my $office = 'boston'; #office to match on my @matched; open(EMPLOYEES, 'employees.txt'); while(<EMPLOYEES>){ chomp; if(/(.*?)\s*(\S*@\S*)\s*(.*$office.*)/i){ push @matched, "$1 $2"; } } print "Employees from $office office:\n"; foreach(@matched){ print "$_\n"; }
|
|---|