Make a word list from a text
Brendan
mailinglist at endosquid.com
Sat Aug 2 05:03:24 UTC 2008
On Friday 01 August 2008, Wulfy wrote:
> I want to take a text file and extract all the words and sort them into
> a unique list. I've looked at split, cut, sed and awk (the last two
This is not exactly correct, but this is a good start...
It's from memory, so it should only be slightly wrong.
#!/usr/bin/perl
my $filename = "foo.txt";
open( FILE, "< $filename" ) or die "Can't open $filename : $!";
my @words;
my @tmp;
while (<FILE>){
@tmp = split(/ /, $_);
push @tmp, "\n";
push @words, @tmp ;
# push @words, (split(/ /, $_));
# push @words, "\n";
}
print @words;
exit;
More information about the kubuntu-users
mailing list