Hi there,
I could use some help with printing array/list contents, rather than
length. In the class I'm taking, we learned that if you print it within
a C-string, the contents will print, but if it's in scalar context (ie.
$a = @a ; print $a) then you'll get the length of the list.
In my script, I don't *think* my array is in a scalar context, but it's
printing the length of the array, not the context. Here's the code, any
ideas?
# declare variables
$" = "," ;
my @alph = (a..z);
#print "@alph\n";
my $word;
my $temp;
my %dwords;
my $c = 0;
my @possWords;
# Create a hash of all the words in the dictionary
open(DICT, etc. ...
#get the user's word
print "Please type an incomplete word where one letter is replaced by a
question mark (e.g. \"th?n\"). \nYour incomplete word? ";
chomp($word = <STDIN>);
$temp = $word ;
@possWords = ($word);
print "\nThis is \@possWords with \$word in it: @possWords\n";
# replace the "?" with each letter of the alphabet and see if that new
word is in dict
foreach $alph(@alph) {
$temp =~ s/\?/$alph/ ;
print "This is \$temp after regexp: $temp\n" ;
if ($dwords{lc($temp)}){
@possWords = push(@possWords,$temp) ;
print "\nThis is \@possWords after pushing \$temp: @possWords\n";
$c++ ;
#print "This is \$c after increment: $c \n" ;
}
$temp = $word;
#print "This is \$temp being \$word again: $temp \n" ;
}
print "Found $c matching words: @possWords\n" ;
print("\nAll done!\n");
exit;
--
Lonya Julin, Web Developer
Terra Lycos
corp.terralycos.com