#! /usr/bin/perl # file: replace # # This script performs a series of search and replace functions on a file. # # Input_list: a list of search and replace pairs, seperated by an equal sign. # std_in: the file to perform the search and replace operations on. # std_out: the new file containing the replace operations. # Written 01 June 2004 by Toby Martin of Figmental Magic # Read the list into memory $list_name = shift; open (SR_FILE, "<$list_name") or die "Unable to open $list_name for reading: $!"; while () { push @SR_LIST, $_; } # Check each line of the text against the list while (<>) { $in_line = $_; foreach $sr_element (@SR_LIST) { $sr_element =~ (/(.*)=(.*)/); $search_for = $1; $replace_with = $2; s/$search_for/$replace_with/g; } print; }