Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: The Deceiver

by sleepingsquirrel (Chaplain)
on Aug 13, 2004 at 15:10 UTC ( [id://382702]=note: print w/replies, xml ) Need Help??


in reply to Why does a Perl 5.6 regex run a lot slower on Perl 5.8?

I must be overlooking something, but why wouldn't this code work to remove all instances of "whatever"...
open (FILE, "a.txt"); $/=undef; $txt = <FILE>; $txt =~ s/whatever//sig;


-- All code is 100% tested and functional unless otherwise noted.

Replies are listed 'Best First'.
Re^2: The Deceiver
by diotalevi (Canon) on Aug 13, 2004 at 15:20 UTC
    Finding the things around 'whatever' is different than just removing 'whatever'.
      My code was just a literal translation of the OP's remark...
      "As you can see, this code slurps a file and removes all occurences of a certain word (`whatever')."


      -- All code is 100% tested and functional unless otherwise noted.
      Take a look at how that extract() routine is used a little more closely...
Re^2: The Deceiver
by perldeveloper (Scribe) on Aug 13, 2004 at 19:35 UTC
    I was trying to make a point about the fact that this code runs incredibly slower on the prepackaged RH9 Perl 5.8.0 compared to the prepackaged (Mandrake 8 I believe) Perl 5.6.1. The example above was whipped up especially for this experiment, after a period of tracking down the exact pieces of code which were slowing down my original Perl programs.

    Only after noticing that the =~ /(.*?) constructs were leading to neverending pauses in the Perl 5.8.0 code, did I realize that adding a ^ anchor would eliminate the inherent ambiguity (the /s switch was on). That's how I made this short example, in which I added the extract subroutine so I can get clear results in the DProf debugger and can make direct comparisons against the Perl versions. I was astounded to see that the slow ratio was not within 1.0 and 2.0 (meaning a tad slower), but somewhere between 500.0 and 1,000.0, explaining why buying new hardware was definitely more expensive than having somebody replace all /(.*?) regexps to /^(.*?) :).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-04-23 18:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found