/o regex question

Discussion in 'Perl Misc' started by smackdab, Oct 24, 2003.

  1. smackdab

    smackdab Guest

    If I use the /o on a regex, is it available package wide for the
    duration of the program or is it bound by some other scope???

    I want to optimize a loop that parses lines from a file...
    smackdab, Oct 24, 2003
    #1
    1. Advertising

  2. smackdab

    J. Gleixner Guest

    smackdab wrote:
    > If I use the /o on a regex, is it available package wide for the
    > duration of the program or is it bound by some other scope???
    >
    > I want to optimize a loop that parses lines from a file...


    Ya might want to look at using qr instead.
    J. Gleixner, Oct 24, 2003
    #2
    1. Advertising

  3. -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    "smackdab" <> wrote in news:pKdmb.42112$hp5.25973
    @fed1read04:

    > If I use the /o on a regex, is it available package wide for the
    > duration of the program or is it bound by some other scope???
    >
    > I want to optimize a loop that parses lines from a file...


    /o means that the regex gets compiled once, and never again until the
    program exits. There is no scope associated with it.

    Internally, when a regular expression with the /o modifier is encountered,
    the perl RE engine first compiles the regular expression, then patches the
    OP tree so that the pattern does not get examined again (it's as if the
    pattern is a constant string at that point).

    - --
    Eric
    $_ = reverse sort $ /. r , qw p ekca lre uJ reh
    ts p , map $ _. $ " , qw e p h tona e and print

    -----BEGIN PGP SIGNATURE-----
    Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

    iQA/AwUBP5mKz2PeouIeTNHoEQI3awCg5Ls01aDG1eaOpjdpwrzqSHXESQMAoOoN
    YtBjtyEY9O0lE55cBybFO6sV
    =feTi
    -----END PGP SIGNATURE-----
    Eric J. Roode, Oct 24, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?SmViQnVzaGVsbA==?=

    Is ASP Validator Regex Engine Same As VS2003 Find Regex Engine?

    =?Utf-8?B?SmViQnVzaGVsbA==?=, Oct 22, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    688
    =?Utf-8?B?SmViQnVzaGVsbA==?=
    Oct 22, 2005
  2. Rick Venter

    perl regex to java regex

    Rick Venter, Oct 29, 2003, in forum: Java
    Replies:
    5
    Views:
    1,604
    Ant...
    Nov 6, 2003
  3. Replies:
    2
    Views:
    589
  4. Xah Lee
    Replies:
    1
    Views:
    927
    Ilias Lazaridis
    Sep 22, 2006
  5. Replies:
    3
    Views:
    726
    Reedick, Andrew
    Jul 1, 2008
Loading...

Share This Page