Re: using local when appropriate

2006-09-29 Thread Chad Perrin
Dammit, I accidentally replied to the OP rather than the list (lo these many hours ago), and only just realized it. -- CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ] Amazon.com interview candidate: "When C++ is your hammer, everything starts to look like your thumb." -- To unsubscribe,

Re: using local when appropriate

2006-09-29 Thread Mumia W.
On 09/29/2006 01:28 PM, Charles K. Clarkson wrote: Derek B. Smith wrote: : ## Below is better pratice ## : : sub getfile { : my $filename = shift; : open F, "< $filename" or die "open failed $!" : my $contents; : { local $/ = undef; # Read entire file at once :$contents = ; # Retur

RE: using local when appropriate

2006-09-29 Thread Charles K. Clarkson
Derek B. Smith wrote: : ## Below is better pratice ## : : sub getfile { : my $filename = shift; : open F, "< $filename" or die "open failed $!" : my $contents; : { local $/ = undef; # Read entire file at once :$contents = ; # Return file as one line : } : close F; : return $content

using local when appropriate

2006-09-29 Thread Derek B. Smith
sub getfile { my $filename = shift; open F, "< $filename" or die "open failed: $!"; my $contents = ''; while () { $contents .= $_; } close F; return $contents; } This is inefficient, because the operator makes Perl go to all the trouble of breaking the file into lines and returning the