Deane,

Parens are needed for capturing.  If you need grouping, you should use 
<wait for it> non-capturing parens:
/^(?:this|that)$/

The diff is, no memory overhead in storing the capture and no <mumble> in 
doing the actual capture.  Just grouping (needed here, I add, perhaps 
unnecessarily) to make sure the anchors "^" and "$" are applied to the 
alternatives as a group, not:
/^this|that$/

which'd really be:
/^this/ or /that$/

Not sure about the /o opt/compile business - it is supposed to compile the 
RE, which is why you *don't* want to use it w/ a var:
foreach my $name ( qw( andy deane george katrina )  ) {
  $_ = "where's $name now?";
  foreach my $re_name ( qw( andy deane george katrina )  ) {
     print "Trying $re_name\n";
     if ( /where's ($re_name)/o ) {
        print "Found $1\n";
      }   # if /where's

  }    # foreach re_name
}     # foreach  name

The RE becomes /where's andy/ the first time through and that's that.

a

Andy Bach, Sys. Mangler
Internet: [EMAIL PROTECTED] 
VOICE: (608) 261-5738  FAX 264-5932

"...when you're trying to build a house of cards, the last thing you 
should do is blow hard and wave your hands like a madman."
   --  Rupert Goodwins
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to