in reply to Parsing a 3-Column Tab-Deliminated File
use strict; use warnings; my $office = shift or die "Usage: $0 office\n"; my %h; my $infile = "employees.txt"; open F, "< $infile" or die "read $infile - $!\n"; while (<F>) { chomp; my( $name, $email, $offices ) = split /\t/; $offices or next; $h{$_}{$name} = $email for split /,\s*/, $offices; } close F; print "$_\t$h{$office}{$_}\n" for sort keys %{ $h{$office} };
|
|---|