I've changed my code to the following:
#!/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;
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.
Update! All fixed, ignore me |