in reply to Parsing a 3-Column Tab-Deliminated File
Sounds like you're looking for split.
while (my $record = <EMPLOYEES>) { chomp $record; my @person = split /\t/, $record; # now do something interesting with @person }
Actually I think I'd use a hash:
my @cols = qw(name email office); while (my $record = <EMPLOYEES>) { chomp $record; my %person; @person{@cols} = split /\t/, $record; # now do something interesting with %person }
Oh, and you should really be checking the return value from open and taking appropriate action.
open (EMPLOYEES, 'employees.txt') or die "Can't open employees.txt: $!\n";
"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
|
|---|