Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > /o regex question

Reply
Thread Tools

/o regex question

 
 
smackdab
Guest
Posts: n/a
 
      10-24-2003
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...



 
Reply With Quote
 
 
 
 
J. Gleixner
Guest
Posts: n/a
 
      10-24-2003
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.

 
Reply With Quote
 
 
 
 
Eric J. Roode
Guest
Posts: n/a
 
      10-24-2003
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

"smackdab" <> wrote in newsKdmb.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/AwUBP5mKz2PeouIeTNHoEQI3awCg5Ls01aDG1eaOpjdpwrzqSH XESQMAoOoN
YtBjtyEY9O0lE55cBybFO6sV
=feTi
-----END PGP SIGNATURE-----
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How make regex that means "contains regex#1 but NOT regex#2" ?? seberino@spawar.navy.mil Python 3 07-01-2008 03:06 PM
String Pattern Matching: regex and Python regex documentation Xah Lee Java 1 09-22-2006 07:11 PM
Is ASP Validator Regex Engine Same As VS2003 Find Regex Engine? =?Utf-8?B?SmViQnVzaGVsbA==?= ASP .Net 2 10-22-2005 02:43 PM
Java regex imposture re: Perl regex compatibility a_c_Attlee@yahoo.com Java 2 05-06-2005 12:16 AM
perl regex to java regex Rick Venter Java 5 11-06-2003 10:55 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57