Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Year end FAQ stubborn answer help, 2006 edition

by ikegami (Patriarch)
on Nov 28, 2006 at 02:24 UTC ( [id://586397]=note: print w/replies, xml ) Need Help??


in reply to Year end FAQ stubborn answer help, 2006 edition

I've been told, but haven't been able to verify when this change took place, that the latest versions of Perl won't recompile a regular expression using interpolation if the variable hasn't changed.

I didn't find any mention of this in perl56delta, perl561delta, the Changes file for 5.6.0, or the Changes file for 5.6.1.

However, it's easy to verify whether a given version has the optimization or not. Since at least 5.6.0,

use re 'debug'; for (1..2) { $re_str = $_; print("***** $_ *****\n"); /$re_str/; } $re_str = "\\d"; for (3..4) { print("***** $_ *****\n"); /$re_str/; }

outputs

***** 1 ***** Compiling REx `1' Guessing start of match, REx "1" against "1"... ***** 2 ***** Compiling REx `2' Guessing start of match, REx "2" against "2"... ***** 3 ***** Compiling REx `\d' Matching REx "\d" against "3" ***** 4 ***** Matching REx "\d" against "4" <--- No "Compiling" before this.

(irrelevant lines omitted).

I've personally tested this with 5.6.0, 5.6.1, 5.8.0 and 5.8.8.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://586397]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-25 23:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found