Re: Slurp large files into an array, first is quick, rest are slow
- From: Kevin Collins <spamtotrash@xxxxxxxxxxxxxxxxxx>
- Date: Wed, 28 Dec 2005 18:39:15 GMT
In article <1135794048.032274.189430@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
gdtrob@xxxxxxxxx wrote:
> I am slurping a series of large .csv files (6MB) directly into an array
> one at a time (then querying). The first time I slurp a file it is
> incredibly quick. The second time I do it the slurping is very slow
> despite the fact that I close the file (using a filehandle) and undef
> the array. here is the relevant code:
>
> open (TARGETFILE,"CanRPT"."$chromosome".".csv") || die "can't open
^^^^^^^^^^^^^
No need to quote this. It should either be:
open (TARGETFILE,"CanRPT".$chromosome.".csv") || die "can't open
or
open (TARGETFILE,"CanRPT$chromosome.csv") || die "can't open
> targetfile: $!";
> print "opened";
> @chrfile = <TARGETFILE>; #slurp the chromosome-specific repeat file
> into memory
> print "slurped";
>
> (and after each loop)
>
> close (TARGETFILE);
Not that it answers your question, but you should be able to close your file
immediately after slurping it in, rather than after a loop...
> undef @chrfile;
>
> If it is possible to quickly/simply fix this I would much rather keep
> this method than setting up a line by line input to the array. The
> first slurp is very efficient.
>
> I am using activestate perl 5.6 on a win32 system with 1 gig ram:
Kevin
--
Unix Guy Consulting, LLC
Unix and Linux Automation, Shell, Perl and CGI scripting
http://www.unix-guy.com
.
- References:
- Prev by Date: Re: Dave Roth's site (Win32::AdminMisc, Win32::ODBC, etc.) not available.
- Next by Date: Re: How to print (2 & (1 * (2**32)))?
- Previous by thread: Slurp large files into an array, first is quick, rest are slow
- Next by thread: Re: Slurp large files into an array, first is quick, rest are slow
- Index(es):
Relevant Pages
|
|