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

Re: Optimizing existing Perl code (in practise)

by Abigail-II (Bishop)
on Aug 19, 2002 at 16:22 UTC ( [id://191228]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Optimizing existing Perl code (in practise)
in thread Optimizing existing Perl code (in practise)

I'd never choose the second method. With the first, it's immediately clear what it does. With the second, it isn't. And somehow I doubt it's faster - it certainly doesn't look like it, as you first make a list of all the lines, then join them together, meaning you get more than double the memory usage. I'd rather do
my $text = do {local (@ARGV, $/) = $file; <>};

"Still do it in Perl" isn't a goal, IMO.

Abigail

Replies are listed 'Best First'.
Re: Re: Optimizing existing Perl code (in practise)
by IlyaM (Parson) on Aug 19, 2002 at 21:05 UTC

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (9)
As of 2024-03-28 10:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found