[EMAIL PROTECTED] wrote on 02/09/2006 12:39:15
PM:
>
>
> Today's Topics:
>
> 5. Help! My regexp has gone insane! ([EMAIL PROTECTED])
>
>
> ------------------------------
>
> Message: 5
> Date: Thu, 9 Feb 2006 11:13:03 -0600
> From: [EMAIL PROTECTED]
> Subject: Help! My regexp has gone insane!
> To: [email protected]
> Message-ID:
>
<[EMAIL PROTECTED]>
>
> Content-Type: text/plain; charset="us-ascii"
>
> 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 problem is that it's testing $value to match //
since you've got nothing there, everything matches it. there isn't even an
undefined value in order to throw a warning or exception error.
at least that is what it looks like. try replacing $#ary with ($#ary-1) so
that
> for my $x (0 .. $#ary) {
becomes
> for my $x (0 .. ($#ary - 1)) {
HTH
-Josh
> Thanks to any who can solve this hairball.
>
> Deane
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: http://ASPN.ActiveState.
>
com/ASPN/Mail/Browse/Threaded/activeperl/attachments/20060209/9aee0782/attachment.
> htm
>
> ------------------------------
>
> _______________________________________________
> ActivePerl mailing list
> [email protected]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>
> End of ActivePerl Digest, Vol 25, Issue 17
> ******************************************
-----------------------------------------
PLEASE NOTE:
SeaChange International headquarters in Maynard, MA is moving!
Effective March 1, 2006, our new headquarters address will be:
SeaChange International
50 Nagog Park
Acton, MA 01720 USA
All telephone numbers remain the same:
Main Corporate Telephone: 978-897-0100
Customer Service Telephone: 978-897-7300
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs