Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • #!/usr/local/bin/perl -w
     
    # $Id: twiddle-regex,v 1.2 1999/10/21 02:00:50 klassa Exp klassa $
     
    ##########################################################################
      # twiddle-regex
    #
    # Inspired by redemo.py in the python 1.5.2 distribution.
    #
    # Author: John Klassa
    # Date:   June, 1999
    #
    # Lets you enter target text as well as a regex, and gives you
    # visual feedback on how the latter does against the former.
    #######################################################################

    • It sez here

          # Compile the regex in an eval block so we don't die.  Is there a
          # good way to tack on regex flags without resorting to the string
          # form of eval?  I like the plain block form better, just for doing
          # try/catch stuff.

          # ...

          $re = eval "qr/\$regex/$flags";

      Unless I'm much mistaken, that can be written more simply as

          $re = eval { qr/(?$flags)$regex/ };