I have a tab delimited that looks somthing like this:
Name City Languages
Hong Xiao Chongqing English,Mandarin
Rob Huston, TX English,German,Japanese
Jess Springfield, IL English,French
Mike Austin, TX English,Perl,Java
ect...
I have written this very cute little program to let you find out who knows which language.
#!/opt/bin/perl -w
use strict; # don't allow unsafe constructs
my ( $name, $city, $language, $search );
my $whole;
my $count = 1;
my $line;
my @matched;
print "What language would you like to search for? ";
$search = <STDIN>;
chomp $search;
#open the employees file
open (EMPLOYEES, "employees.txt");
#for each line
while ($line = <EMPLOYEES>) {
#remove the carriage return
chomp $line;
#splits the line between tabs and get the different elements
($name, $city, $language) = split /\t/, $line;
next unless $language =~ /^$search/;
print "$name speaks $search\n";
}
close (EMPLOYEES);
The only problme is that right now it only works for the entry "English" because the other languages are buried English without spaces (only commas). What is the fastest way to parse the elements assigned to the $language $scaler?
Thanks for your time and any help offered.