L
LANkrypt0
I wrote the following code and for some reason it does not exit when my
$word is the same as $ARGV[0].
Can anyone shed some light on this for me?
Is it because it needs to actually run through every foreach loop?
Thanks
==+ BEGIN CODE +==
#!/usr/bin/perl
use strict;
my @valpha = ("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");
my $word;
until ($word eq $ARGV[0])
{
foreach my $letter1 (@valpha)
{
foreach my $letter2 (@valpha)
{
foreach my $letter3 (@valpha)
{
foreach my $letter4 (@valpha)
{
foreach my $letter5 (@valpha)
{
$word = $letter1.$letter2.$letter3.$letter4.$letter5;
print "$word\n";
}
}
}
}
}
}
print "Word found!\n";
==+ END CODE +==
$word is the same as $ARGV[0].
Can anyone shed some light on this for me?
Is it because it needs to actually run through every foreach loop?
Thanks
==+ BEGIN CODE +==
#!/usr/bin/perl
use strict;
my @valpha = ("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");
my $word;
until ($word eq $ARGV[0])
{
foreach my $letter1 (@valpha)
{
foreach my $letter2 (@valpha)
{
foreach my $letter3 (@valpha)
{
foreach my $letter4 (@valpha)
{
foreach my $letter5 (@valpha)
{
$word = $letter1.$letter2.$letter3.$letter4.$letter5;
print "$word\n";
}
}
}
}
}
}
print "Word found!\n";
==+ END CODE +==