syn
07-28-2001, 03:02 PM
Hi all, can anyone help me out? Ive got a script Im writing to join wordlists together, lowercase everything, sort in alphabetical order, then eleminate duplicate words (all but one of course) and then write to a out.txt file, (its not finished yet, i havnt implemented the duplicate words part but Im damn close) the problem Im having is that the sort function isnt working right with my script for some reason, its probably because I dont fully understand regular expressions but still Im stumped on what is causing the problem. If I write my own array
@something = qw(apple orange grape bananna);
and then @something = sort @something; it works great printing out all the words in the array in alphabetical order but for some reason it doesnt work in my script. I dont want anyone to do it for me since this is a great learning experience for me, just a push in the right direction :) thanx a million for anyone who helps
ps heres the nasty script got me pulling out my hair:
#!/usr/bin/perl
#
# Dictionary Helper Application Script
#
# first see what we have in the current directory and read in all files
# trap so we dont cream any already created wordlists
$name = "out.txt";
if (-e $name) {
print "Out.txt exists, move or rename it."
#exit 1; # this doesnt compile right for some reason
}
print "Reading in some files\n";
open(FILE,"1.txt") ||
die "I cant read: $!";
@wordlist1 = <FILE>;
close (FILE);
open(FILE,"2.txt") ||
die "I cant read: $!";
@wordlist2 = <FILE>;
close (FILE);
#join files into a single array
print "Joining files\n";
@wordlist1 =(@wordlist1, @wordlist2);
#now we should go through and remove caps
print "Converting to lowercase\n";
@wordlist1 = ("\L@wordlist1\n");
print @wordlist1;
print "Alphebetizing wordlist\n";
@wordlist1 = (sort @wordlist1);
print @wordlist1; #this doesnt sort for some reason
@something = qw(apple orange grape bananna);
and then @something = sort @something; it works great printing out all the words in the array in alphabetical order but for some reason it doesnt work in my script. I dont want anyone to do it for me since this is a great learning experience for me, just a push in the right direction :) thanx a million for anyone who helps
ps heres the nasty script got me pulling out my hair:
#!/usr/bin/perl
#
# Dictionary Helper Application Script
#
# first see what we have in the current directory and read in all files
# trap so we dont cream any already created wordlists
$name = "out.txt";
if (-e $name) {
print "Out.txt exists, move or rename it."
#exit 1; # this doesnt compile right for some reason
}
print "Reading in some files\n";
open(FILE,"1.txt") ||
die "I cant read: $!";
@wordlist1 = <FILE>;
close (FILE);
open(FILE,"2.txt") ||
die "I cant read: $!";
@wordlist2 = <FILE>;
close (FILE);
#join files into a single array
print "Joining files\n";
@wordlist1 =(@wordlist1, @wordlist2);
#now we should go through and remove caps
print "Converting to lowercase\n";
@wordlist1 = ("\L@wordlist1\n");
print @wordlist1;
print "Alphebetizing wordlist\n";
@wordlist1 = (sort @wordlist1);
print @wordlist1; #this doesnt sort for some reason