On Jul 23, 2004, at 8:14 AM, [EMAIL PROTECTED] wrote:
Hi James,
Hello again.
I was trying this but not sure where it is going wrong ...
There you go. Now I'll help... ;)
use strict; use File::Copy;
You import, but do not use the above module. We don't need it.
my $dest_file = "sendToAdapter.properties"; my $searchstr = 'sample'; my $repstr = 'FileAdapter';
open(FL, $dest_file) or die("Doh - $!");
$^I = '~';
I believe the above trick only works with the <> construct. You're using a filehandle, so it's not active.
s/$searchstr/$repstr/g while <FL>;
You are reading in the line and altering it. What you are forgetting to do it to print it back out.
close(FL);
Would appreciate if you could help me.
I'll sure try. Here's my corrected version of your script:
#!/usr/bin/perl
use strict; use warnings; # a good idea, helps us find mistakes easier
push @ARGV, "sendToAdapter.properties"; # add to @ARGV, which <> processes
local $^I = '~'; # set inplace editing
my $searchstr = 'sample'; my $repstr = 'FileAdapter';
while (<>) { # read s/$searchstr/$repstr/g; # change print; # write }
__END__
Hope that helps.
James
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>