in reply to Loops and comparisons
I'm not sure what you're after exactly, but I suppose you want the first "loop" to match when the third character is neither a 'c' nor a 'd'. Hence the condition should read
if ($third_char ne 'c' && $third_char ne 'd'){ $part=substr($stri,0,2);
Incidently, there are more elegant ways to check whether $second_char is in @one. Have a look at grep, or alternatively, you can use a regexp.
Both approaches eliminate the need for the for loop.my $regexStr = join("|", @one); my $regex = qr/^$regexStr$/; ... if ($second_char =~ $regex) { ...
Hope this helps, -gjb-
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Loops and comparisons
by perl_seeker (Scribe) on Oct 16, 2003 at 06:31 UTC |