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,
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
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
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