N
nicolas-laurent
Hi all,
Am trying to write a Perl script that will read a line from a file and
number each word.
house operas ray sun doctor lilo
1 house
2 operas
3 ray
4 sun
5 doctor
6 lilo
#!/usr/bin/perl
while (<>) {
@words = split(/\W*\s+\W*/, $_); # split into words
foreach $word (@words) {
$wordnumber{$word}++; # count the words
}
}
print $wordnumber{$word}, $word;
}
I have difficulty to figure out how to do it.
Am trying to write a Perl script that will read a line from a file and
number each word.
house operas ray sun doctor lilo
1 house
2 operas
3 ray
4 sun
5 doctor
6 lilo
#!/usr/bin/perl
while (<>) {
@words = split(/\W*\s+\W*/, $_); # split into words
foreach $word (@words) {
$wordnumber{$word}++; # count the words
}
}
print $wordnumber{$word}, $word;
}
I have difficulty to figure out how to do it.