Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Here's the code:
Thanks, Sam#!/usr/bin/perl -w print "Please Enter the Name of a File: "; $file = <STDIN>; if (open(HANDLE, "$file")) { print "Please Enter a word from $file: "; $word_1 = <STDIN>; print "Please Enter a Word to Replace, $word_1, with: "; $word_2 = <STDIN>;} @x=<HANDLE>; open (HANDLE, "$file"); open (HANDLE, ">>$file"); foreach $variable (@x) { if ($word_1=~/$variable/i) { $variable = $word_2; print @x;}}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: swaping words
by VSarkiss (Monsignor) on Feb 11, 2002 at 00:12 UTC | |
|
Re: swaping words
by BazB (Priest) on Feb 10, 2002 at 23:56 UTC |