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

Re: [Fun With Perl] crunching the modules at @INC



>From vlb@cfcl.com  Wed Jun 16 12:20:05 1999 - apologies for the delay - vlb]
Message-ID: <19990616174849.21264.qmail@plover.com>
In-reply-to: Your message of "Wed, 16 Jun 1999 12:51:25 EDT."
              <19990616125125.D12767@linguist.dartmouth.edu>
Date: Wed, 16 Jun 1999 13:48:49 -0400


> /o is only meaningful when the pattern contains variables.  It doesn't do
> any harm if the pattern is constant, but it doesn't do any good either.

I had a fantasy that it would postpone compilation of the regex until
the moment the regex is first needed, so that if you had some big fat
regex that was in a conditional block, you could put /o onto it and
then it wouldn't ever be compiled unless the condition did turn out to
be true sometime.

But it turns out that it doesn't do that unless the regex contains variables.

So here's a rather bizarre hack:

if (some condition) {
   my $: = '';
   ...   /SOME HORRENDOUS
     REGEX
	(?<!HERE)
	(?!(?:(?(?{....})YOB|GORGLE)))
     BLAH BLAH BLAH
     $:  # Empty string
    /xo;
}

The presence of $: inside the regex *does* force Perl to defer its
compilation until run-time, and if `some condition' is always false,
it's never compiled at all.

Seems like a pretty stupid hack, actually.  It would probably make
more sense to write

if (some condition) {
   my $regex = 'SOME HORRENDOUS ... BLAH';
   ...
   /$regex/xo;
}

Oh well, these thnigs don't always turn out to be useful.

==== Want to unsubscribe from this list? (Don't you love us anymore?)
==== Well, if you insist... Send mail with body "unsubscribe" to
==== fwp-request@technofile.org

</x-flowed>