I have this perl program and i want to compare the letters of the alphabet against the letters i input. However when compare it says everyletter in the alphabet is a true match of every letter i input i.e. A = F . The line of code in question is
if (@letters[$letter] == @alphabet[$alpha])
My full code is posted below if the error lies somewere else, i know this is a proper childish question but i am new to perl and trying to understand. Thanks for any help given. Paul
#!/usr/bin/perl
#Create a Program that filters 500,000 words
#down to words only with certain letters in "A D E F G H K S U Z"
$var = <STDIN>; #16 at most
chomp($var);
@letters = split(/,/, $var);
@alphabet = qw(a b c d e f g h i j k l m n o p q r s t u v w x y z); #26
$letter = 0;
$alpha = 0;
while ($alpha < 26)
{
$negletters = 0;
while ($negletters <16)
{
if (@letters[$letter] == @alphabet[$alpha])
{
@currentletter = splice(@alphabet,0,1);
#delete @alphabet[$alpha]; #delete the correspoding letter in alphabet
$negletters = 16;
}
else
{
$alpha ++;
$negletters ++;
}
}
$letter ++;
}
exit;
if (@letters[$letter] == @alphabet[$alpha])
My full code is posted below if the error lies somewere else, i know this is a proper childish question but i am new to perl and trying to understand. Thanks for any help given. Paul
#!/usr/bin/perl
#Create a Program that filters 500,000 words
#down to words only with certain letters in "A D E F G H K S U Z"
$var = <STDIN>; #16 at most
chomp($var);
@letters = split(/,/, $var);
@alphabet = qw(a b c d e f g h i j k l m n o p q r s t u v w x y z); #26
$letter = 0;
$alpha = 0;
while ($alpha < 26)
{
$negletters = 0;
while ($negletters <16)
{
if (@letters[$letter] == @alphabet[$alpha])
{
@currentletter = splice(@alphabet,0,1);
#delete @alphabet[$alpha]; #delete the correspoding letter in alphabet
$negletters = 16;
}
else
{
$alpha ++;
$negletters ++;
}
}
$letter ++;
}
exit;