[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] A tiny bit of fun with a regex



On Fri, Aug 13, 1999 at 05:51:05PM -0400, John Porter wrote:
> On Fri, Aug 13, 1999 at 04:05:53PM -0500, Brand Hilton wrote:
> >
> > > >   print "found it\n" if /\d+
> > > >                          \/
> > > >                          \d+  # find something of the pattern y/x
> > > >                         /x
> > 
> > I ran across it when I had the phrase "and/or" in a regex comment. 
> > I thought maybe I could hide it a little bit and make it more
> > challenging to find.  Apparently not :-)
> 
> What if you change the delimiters:
> 
>   m{
>     \d+
>     /
>     \d+  # find something of the pattern y/x
>   }x

Yeah, that fixes it.  The thing that surprised me when it first bit me
was that it was treating something as an end-of-pattern delimiter
which I had meant to be inside a comment.  From my POV as a coder,
that's what it looked like.

But, of course, perl has no way of knowing whether "x" mode is on until
it finds the end-of-pattern delimiter and looks at the flags.  

'Course, I'm just restating the obvious at this point, so I think I'll
just go home :-)

-- 
 _____ 
|///  |   Brand Hilton  bhilton@adc.com
|  ADC|   ADC Telecommunications
|_____|   Richardson, Texas

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe