Rob Dixon wrote:
>
> Nelson Ray wrote:
> > Just as a little background, I am working on a BioInformatics program
> > that runs on large (about 300 meg) text files. I am using a
> > filehandle to open and load it into an array. Then I use the join
> > command to read the array into a scalar variable in order to be in a
> > workable form for my computationally intensive program.
>
> My first thought is that you're wasting space here by duplicating the
> file's contents into both the array and the scalar. Just read directly
> into the scalar (by enabling 'slurp' mode) like this:
>
> my $contents;
> {
> local $/;
> open FILE, "< file.txt";
You should _always_ verify that the file opened successfully.
> $contents = <FILE>;
> close FILE;
> }
my $contents = do {
open my $fh, 'file.txt' or die "Cannot open 'file.txt' $!";
local $/; <$fh> };
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]