/o regex question

S

smackdab

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...
 
J

J. Gleixner

smackdab said:
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.
 
E

Eric J. Roode

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

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-----
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top