This is my script.

===
#!/usr/bin/perl
# ex9-2b.pl

use strict;
use warnings;

my ($filename) =  @ARGV;

open FILE, $filename or die "Can't open $filename : $!";

$^I = ".out";  
while (<FILE>) {
   s/Fred/Larry/i;
   print;
}
===

I executed using:
$ perl ex9-2b.pl fred_larry.txt
AlLarry
Larrydy
Larrydy Mercury
Wilma
wilma
Larry
Larrydo
freedo
Antonius AlLarry
Mr. AlLarry
Mr. Larrydy
Mrs. Larrydy Mercury
Ms. Wilma
Ms. wilma
Mr. Larry
Mrs. Larrydo
Mr. freedo
Antonius J. AlLarry
Larry
Larry
Larry
Mr. Larry and Mrs. Wilma
Larry and Wilma
Wilma Larry
Larrywilma

It does the work s/Fred/Larry/i but why didn't want to print back to the 
file.

I'm using different approach like below:

===
#!/usr/bin/perl
# ex9-e.pl

use strict;
use warnings;

$^I = ".out";

while (<>) {
   s/Fred/Larry/i;
   print;
}  
===

It does the replacement and print back. Why differs?

thx
.dave

http://www.davidsudjiman.info

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to