[Techtalk] On Perl
gab
gab at gorge.net
Fri Jul 26 11:55:04 EST 2002
> to be honest, this code is horrible hehe .. i hope it is just for
> educational purposes to show possible uses of if, elsif, etc.
>
> > $i = 0; // the index of the array is set to zero
> > $correct = "maybe"; {
> > while ($correct eq "maybe")
> > {
> > if ($words[$i] eq $guess){ // if this index of @words == $guess
> > $correct = "yes"; // $then set correct to yes
> > } // and break the loop
> > elsif ($i < 2) { // otherwise
> > $i = $i + 1; // increment the index to check the next
> // element in @words
>
<snip>
> to be honest, this is poorly written code .. so if it's confusing, don't
> think it's just you hehe. if you need any more perl help, let me know :)
Coldie,
I'm curious as to what makes this poorly written. I think that a better
way to do something like this would be to use a hash instead of an
array; what else?
If this is going too OT for the Linuxchix list, please email me
privately. Thanks!
gabrielle, still a perl newbie after all these years.
More information about the Techtalk
mailing list