www.pudn.com > sphinx_recipe.zip > StripText.pl


#!/usr/bin/perl

# Strips one or more bits of text from every line in a text file.
#
# Copyright 2006 by Keith Vertanen
#

use strict;

if ( @ARGV < 2 )
{
    print "$0   [text2] ...\n"; 
    exit(1);
}

my $indexFile;
my $line;
my $i;
my $pos;

($indexFile) = @ARGV;

open(IN, $indexFile);

while ($line = ) 
{
    $line =~ s/\n//g;
    $line =~ s/\r//g;

    for ($i = 1; $i < scalar @ARGV; $i++)
    {
	$pos = index($line, $ARGV[$i]);
	while ($pos != -1)
	{
	    $line 	= substr($line, 0, $pos) . substr($line, $pos + length($ARGV[$i]));
	    $pos 	= index($line, $ARGV[$i]);
	}
    }
    print $line . "\n";
}
close IN;