in reply to Re: Running out of memory...
in thread Running out of memory...
auburn_courses.txt contains a load of html files all bunched one after the other...I'd like to remove the bits between the footer of one section that I want to see and the header of the next section that I'd like to see. They're delimited by the $a and $b lines.#!/usr/local/bin/perl -w use strict; open IN, '< :raw', $ARGV[ 0 ] or die "$ARGV[ 0 ] : $!"; open OUT, '> :raw', $ARGV[ 1 ] or die "$ARGV[ 1 ] : $!"; my $a = '<!-- rsecftr.htm - Course Sections Table Footer -->'; my $b = '<!-- rsechdr.htm - Course Sections and Course Section Search +Table Header -->'; my $buffer; sysread IN, $buffer, 5800, 5800; do{ ## Move the second half of the buffer to the front. $buffer = substr( $buffer, 5800 ); ## and overwrite it with a new chunk sysread IN, $buffer, 5800, length( $buffer ); ## Apply the regex $buffer =~ s|$b(.*?)$a||g; print $buffer; ## Write out the first half of the buffer syswrite OUT, $buffer, 5800; } until eof IN; close IN; close OUT;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Running out of memory...
by BrowserUk (Patriarch) on Jan 29, 2005 at 21:11 UTC | |
by knewter (Novice) on Mar 03, 2005 at 20:22 UTC |