[OT] - subthread - perl vs sed Re: [olug] Text search and Replace
Jay Hannah
jay at jays.net
Tue Nov 25 19:41:55 UTC 2003
On Tuesday, November 25, 2003, at 11:20 AM, Brian Roberson wrote:
> While I am a huge fan of perl, I must say that it is overkill on
> things like
> this, say you had directory with 50,000 files... just think about
> spawning
> perl 50,000 time's vice sed plus the overhead that perl would add if
> the
> files where 10Mb+ in size. AFAIK - perl would load 10Mb into resident
> mem
> before even doing the substitution. sed uses the file control function
> fseek
> when you give it a filename instead of standard out.
Blasphemer! -grin-
perl -i -e 's/foo/bar/g' myfiles*.txt
Does not spawn 50,000 perl's. There's just one perl whacking the 50,000
files. You could very well be right about 10MB of resident mem. But if
you don't have 10MB of memory free do you really have an appropriate
server for whacking 50,000 10MB+ files? -grin-
I'd take the time to benchmark the speed of "perl -i" vs. sed, but I'm
too lazy*.
Call me a zealot, but IMHO it's a good idea to learn Perl once rather
than learning sed _and_ awk. Learn one thing instead of two, plus you
can then do sooo much more than both combined. Ah, Perl. The Swiss Army
Chainsaw of text processors**.
Jay Hannah
Local Perl Zealot
Omaha Perl Mongers: http://omaha.pm.org
* ... and impatient, and full of hubris. -grin-
** ... and database manipulators, network service creator/consumers,
etc...
More information about the OLUG
mailing list