Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Large scale search and replace with perl -i

by Improv (Pilgrim)
on Apr 14, 2003 at 19:23 UTC ( [id://250384]=note: print w/replies, xml ) Need Help??


in reply to Large scale search and replace with perl -i

One thing you might consider, given that you're willing to put the time into asking on Perlmonks, is using find2perl -- it should be a lot more efficient than actually using find.
  • Comment on Re: Large scale search and replace with perl -i

Replies are listed 'Best First'.
Re: Large scale search and replace with perl -i
by Abigail-II (Bishop) on Apr 14, 2003 at 19:29 UTC
    Is it? I'd like to see some benchmark. It's certainly not my impression, and I don't find it logically, find being a C program written to do exactly one task.

    Abigail

      The reason it should be, apart from it being suggested to be so in the find2perl manpage (hehe), is that process creation is a fairly expensive operation, and it usually is the case that all the spawnings of perl (or anything else that perl can easily duplicate in functionality) are going to slow down the entire operation enough that a single-process all-perl implementation will outpace it by a good margin. Of course, your milage may vary.
        But with the use of xargs, there won't be many spawnings of perl. Furthermore, given that the number of files was supposed to be large, I'd expect the entire process to be IO bound. Finally, yeah, process creation is a fairly expensive operation, but so is calling a function in Perl. And that function will be called for each file in the directory tree, as compared to calling a perl instance for every couple of hundred files matching the criteria.

        Convince me with benchmarks.

        Abigail

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2024-04-19 14:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found