in reply to Reading (the same) data in different ways & memory usage
This doesn't answer your question but:
sub ReadData ($$) { my ($self, $filename) = @_; my $ar_returnvalue = []; if (!-e "$filename") { Carp::carp("File [$filename] does not exist"); return undef; } open (FLATFILE, '<', $filename) or Carp::croak("Cannot open file [ +$filename]"); while (<FLATFILE>) { chomp; push (@{$ar_returnvalue}, Interfaces::FlatFile::ReadRecord($se +lf, $_)); } close (FLATFILE); return $ar_returnvalue; } ## end sub ReadData ($$)
You are using prototypes but prototypes were introduced to allow programmers to imitate Perl's built-in functions, not for user code per se. FMTEYEWTK on Prototypes in Perl
You are testing for the existence of a file twice, first with stat and then with open. In the stat test you are unnecessarily copying the file name to a string before testing it. What's wrong with always quoting "$vars"?
You should include the $! variable in your error messages so you know why they failed.
$hr_returnvalue->{$CurrentColumnName} =~ s/^\s*(.*?)\s*$/$1/; + # Trim whitespace
That is usually written as:
s/^\s+//, s/\s+$// for $hr_returnvalue->{$CurrentColumnName}; + # Trim whitespace
Which avoids unnecessary substitution.
if ($self->datatype->[$_] =~ /^(?:CHAR|VARCHAR|DATE|TI +ME|DATETIME)$/) { $hr_returnvalue->{$CurrentColumnName} = sprintf (" +%s", $self->standaard->[$_]); } else { $hr_returnvalue->{$CurrentColumnName} = $self->sta +ndaard->[$_]; }
What is the sprintf doing that the simple assignment is not doing? It looks like you don't need this test at all.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Reading (the same) data in different ways & memory usage
by Neighbour (Friar) on Apr 21, 2011 at 08:07 UTC | |
by jwkrahn (Abbot) on Apr 21, 2011 at 10:59 UTC |