User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Perl section within the Software Development category of DaniWeb, a massive community of 426,013 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,588 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Perl advertiser: Programming Forums
Views: 716 | Replies: 3 | Solved
Reply
Join Date: Jun 2008
Posts: 74
Reputation: raul15791 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 7
raul15791 raul15791 is offline Offline
Junior Poster in Training

Comparing items in arrays

  #1  
Jul 9th, 2008
Hi,

I try to compare items in two different arrays. This loop works well in another program of mine. But not in the current program i'm working on. Weird....

The output of the program shows
Nested quantifiers in regex; marked by <-- HERE........
  1. for $3 (@obsolete_class_declare)
  2. {
  3. for $4 (@classB)
  4. {
  5. if ($4 =~ /$3/i) #This line causing problem
  6. {
  7. print "$4\n";
  8. last;
  9. }
  10. }
  11.  
  12. }
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2008
Posts: 74
Reputation: raul15791 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 7
raul15791 raul15791 is offline Offline
Junior Poster in Training

Re: Comparing items in arrays

  #2  
Jul 9th, 2008
I found the problem already. I put "**" in the arrays which causes some data reading problem. Solved!
Reply With Quote  
Join Date: Mar 2006
Posts: 620
Reputation: KevinADC is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 33
KevinADC's Avatar
KevinADC KevinADC is offline Offline
Practically a Master Poster

Re: Comparing items in arrays

  #3  
Jul 9th, 2008
You should not use numbered scalar variables in your perl programs, $1 and $2 and etc are used internally by perl for pattern memory and are read only. If you have meta characters in your array elements just use the \Q option to escape them:

$foo =~ /\Q$bar/;

stuff like ** will be interpreted literally, but $ and @ will still be treated like a variable and interpolated.
Reply With Quote  
Join Date: Jun 2008
Posts: 74
Reputation: raul15791 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 7
raul15791 raul15791 is offline Offline
Junior Poster in Training

Re: Comparing items in arrays

  #4  
Jul 9th, 2008
Thanks for the info!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Perl Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Perl Forum

All times are GMT -4. The time now is 1:06 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC