At 12:42 PM 5/3/01 -0400, Rex Posadas wrote:
>******** Start of Code ***************
>$oldWord = "Orange";
>$newWord = "Apple";
>
>$^I=".bk";
>
>while (<>) {
> $_ =~ s/$oldWord/$newWord/g;
> print;
>}
>******** End of Code ***************
>
>This code replaces any occurance of "Orange" so the word "MyOrange" will
>be changed to "MyApple". I would like to change this so that "Orange" is
>the only one that is replaced by the string "Apple".
Replace your substitution line with:
$_ =~ s/\b$oldWord\b/$newWord/g;
The "\b" matches a word boundary.
Steve
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users