| | |
Comparing items in arrays
Please support our Perl advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Jun 2008
Posts: 89
Reputation:
Solved Threads: 7
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
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........ PERL Syntax (Toggle Plain Text)
for $3 (@obsolete_class_declare) { for $4 (@classB) { if ($4 =~ /$3/i) #This line causing problem { print "$4\n"; last; } } }
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.
$foo =~ /\Q$bar/;
stuff like ** will be interpreted literally, but $ and @ will still be treated like a variable and interpolated.
![]() |
Similar Threads
- Parallel Array Help (C++)
- Array Sorting on a User Supplied Element (Java)
- Need help tweaking my program (Java)
- Comparing arrays (C++)
Other Threads in the Perl Forum
- Previous Thread: Regex A-Z, a-z, 0-9, spaces, _s
- Next Thread: Crypt::Blowfish / Crypt::CBC
Views: 1287 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for Perl





