Form Letter Using Regular Expressions
Here's a simple form letter:
Dear ,
You have been selected as the winner of a ! Free!
We know that a will be enjoyed by everyone in
the household. Yes, , this is your lucky
day. Be sure to contact us at ...
Here's a script which fills in the blanks:
#!/usr/bin/perl -w
$first = "John";
$last = "Jones";
$prize = "six-pack of soda";
while(<>){
s//$first/g;
s//$last/g;
s//$first $last/g;
s//$prize/g;
print;
}
#use: ./form_letter.pl form.letter
ASSIGNMENT: