> Help me Mister Wizard!
> 
> I'm testing for membership in an array, using:
> 
> sub listed
> {
> my $value = shift;
> my @ary = @_;
> 
>    my $rtn = 0;
> 
>    print $NEW_INIFILE "Testing value >$value<\n";
> 
>    for my $x (0 .. $#ary) {
> 
>       print $NEW_INIFILE "... against >$ary[$x][1]<\n";
> 
>       if ($value =~ /$ary[$x][1]/) {
>          print $NEW_INIFILE "found match! >$value< vs. >$ary[$x][1]<\n";
>          ++$rtn;
>       }
>    }
> 
>    return( $rtn );
> 
> }
> 
> As of 15 minutes ago, suddenly the n+1'th member of the array is MATCHING 
> $value.  Here's an iteration of the debug prints from the above loop...
> 
> Testing value >RX_43_0_0_001.gho<
> ... against >BK_50_0_0_001.gho<
> ... against >BT_50_0_0_001.gho<
> ... against >RX_42_0_0_001.gho<
> ... against >OF_50_0_0_001.gho<
> ... against >BT_47_0_0_001.gho<
> ... against >RX_40_0_0_001.gho<
> ... against >OF_47_0_0_001.gho<
> ... against >BT_44_0_0_001.gho<
> ... against >RX_38_0_0_001.gho<
> ... against >RX_36_0_0_001.gho<
> ... against >OF_44_0_0_001.gho<
> ... against >OF_41_0_0_001.gho<
> ... against ><
> found match! >RX_43_0_0_001.gho< vs. ><
> 
> So what the argle-bargle's gone wrong? Anybody?  I'm clueless.....

The most likely cause is that in regexes, $ary[$x][1] is ambiguous because [1] 
could be either a character class or a subscript. If [1] is meant to be a 
subscript, use ${ary[$x][1]}; if not, use ${ary[$x]}[1].


--
Eric Amick
Columbia, MD

_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to