I would suggest using something like the following, where INFILE is the
filehandle of your textfile:
my $NewLine = "";
my $TheLine = "";
#read in 500 characters from INFILE until INFILE is exhausted
while (read(INFILE,$NewLine,500)) {
# concat $NewLine to the end of the existing $TheLine
$TheLine .= $NewLine;
# look for match in $TheLine
if ($TheLine =~ /short bit of text/) {
#figure out where in $The Line it matched and go forward and back
}
# keep only the last 300 characters of $TheLine,
# in case the match happens at the beginning of
# the next $NewLine
$TheLine = substr($TheLine,-300);
}
-----Original Message-----
From: Hans Holtan [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 28, 2002 9:13 AM
To: [EMAIL PROTECTED]
Subject: searching a large file
I am having a problem searching a large (600 mb) text file. What I
need to do is find a match with a short bit of text and then look up
to 200 characters forwards and backwards for other matches to
different short bits of text. I tried reading the file to memory
first and then doing the search, but it's a serious hog, and I need
to leave a lot of memory open for other operations. Does anyone have
suggestions on how I can do this while limiting memory usage, speed
is a factor but not paramount.
Thanks,
Hans
--
________________________________________________
Hans E. E. Holtan
Graduate Student
UC Berkeley-Department of Plant and Microbial Biology
Plant Gene Expression Center
800 Buchanan Street
Albany, California 94710
U. S. A.
Phone: (510) 559-5922
FAX: (510) 559-6089
[EMAIL PROTECTED]
_________________________________________________
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]