#!/usr/bin/perl -w use IO::File; my @foo; while (<>) { if (/\\include{(.+?)}/ && $1 !~ /^part-/) { push @foo, $1; } } my $fh = new IO::File "indextmpl.html", "r"; while (<$fh>) { if (/-- INDEXLINES --/) { print "\n"; } else { print; } }