[Fwd: Bioperl: manipulating long strings (genomes) in PERL]
Matthew Pocock
mrp@sanger.ac.uk
Tue, 30 Mar 1999 11:13:56 +0100
This is a multi-part message in MIME format.
--------------E9DCEF923FD08DDF585C80A1
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
--------------E9DCEF923FD08DDF585C80A1
Content-Type: message/rfc822
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Return-Path: <mrp@sanger.ac.uk>
Received: from sanger.ac.uk (infopc9 [193.62.206.148])
by jess.sanger.ac.uk (8.8.8/8.8.7) with ESMTP id LAA00654;
Tue, 30 Mar 1999 11:11:39 +0100 (BST)
Message-ID: <3700A335.6865EE2E@sanger.ac.uk>
Date: Tue, 30 Mar 1999 11:11:01 +0100
From: Matthew Pocock <mrp@sanger.ac.uk>
Organization: The Sanger Center
X-Mailer: Mozilla 4.5 [en] (WinNT; I)
X-Accept-Language: en
MIME-Version: 1.0
To: Ian Korf <ikorf@sapiens.wustl.edu>
Subject: Re: Bioperl: manipulating long strings (genomes) in PERL
References: <199903291901.NAA02346@genotype.wustl.edu>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mozilla-Status2: 00000000
Or even
my $seq = join "", grep { chomp } <FH>;
which also avoids some re-alocation issues
Ian Korf wrote:
> Is it possible you have code that does something like this?
>
> my $seq = "";
> while (<FH>) {
> chomp;
> $seq .= $_
> }
>
> If so, you may be causing reallocations as Perl keeps the scalar contiguous.
> Here's an approach that should work better.
>
> my $seq;
> LOCAL_BLOCK: {
> my @seq = <FH>;
> chomp @seq;
> $seq = join("", @seq);
> }
>
> Now you only have to allocate the scalar once. The local block there is
> just forcing garbage collection of @seq;
>
> -Ian
> =========== Bioperl Project Mailing List Message Footer =======
> Project URL: http://bio.perl.org/
> For info about how to (un)subscribe, where messages are archived, etc:
> http://www.techfak.uni-bielefeld.de/bcd/Perl/Bio/vsns-bcd-perl.html
> ====================================================================
--------------E9DCEF923FD08DDF585C80A1--
=========== Bioperl Project Mailing List Message Footer =======
Project URL: http://bio.perl.org/
For info about how to (un)subscribe, where messages are archived, etc:
http://www.techfak.uni-bielefeld.de/bcd/Perl/Bio/vsns-bcd-perl.html
====================================================================