Re: How do it do find and replace specific words using perl

2004-07-23 Thread James Edward Gray II
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 ;
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]
 



RE: How do it do find and replace specific words using perl

2004-07-23 Thread Anand . V

Hi James,

I was trying this but not sure where it is going wrong ...

use strict;
use File::Copy;

my $dest_file = "sendToAdapter.properties";
my $searchstr = 'sample';
my $repstr= 'FileAdapter';

open(FL, $dest_file) or die("Doh - $!");

$^I = '~';
s/$searchstr/$repstr/g while ;

close(FL);

Would appreciate if you could help me.

Thanks & Regards,
Anand




-Original Message-
From: James Edward Gray II [mailto:[EMAIL PROTECTED]
Sent: Friday, July 23, 2004 6:18 PM
To: [EMAIL PROTECTED]
Subject: Re: How do it do find and replace specific words using perl 


On Jul 23, 2004, at 5:13 AM, [EMAIL PROTECTED] wrote:

> Hi All,

Hello.

> Could some help me in doing this using perl.

We will "help", yes, but we probably won't write it for you.  What have 
you tried.  Where are you stuck?  Show us some code.

James


Re: How do it do find and replace specific words using perl

2004-07-23 Thread James Edward Gray II
On Jul 23, 2004, at 5:13 AM, [EMAIL PROTECTED] wrote:
Hi All,
Hello.
Could some help me in doing this using perl.
We will "help", yes, but we probably won't write it for you.  What have 
you tried.  Where are you stuck?  Show us some code.

James
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



How do it do find and replace specific words using perl

2004-07-23 Thread Anand . V
Hi All,

Could some help me in doing this using perl.

1. Open a text file (Adapter.data ) with following contents.

HEADER.JMSDestination=sample_dataQ
HEADER.JMSDeliveryMode=Persistent
HEADER.JMSType=Data
HEADER.JMSCorrelationID=2
HEADER.JMSPriority=4

PROPERTY.STRING.Data_Type=Purchase_Order
PROPERTY.STRING.Data_Qualifier=Update
PROPERTY.STRING.Data_Delivery_Mode=Notification
PROPERTY.STRING.Data_Format=OPEN
PROPERTY.LONG.TimeToLive=200
PROPERTY.STRING.Src_Client_Addr=godavari::SendToAdapter
PROPERTY.STRING.Src_Client_Version=1.0
PROPERTY.STRING.Src_Client_Type=TestHarness

specific.Directory=/home/anand/Demo/ADK/temp/sendToAdapter
specific.RequestTimeOut=5

specific.DataFile=/home/anand/Demo/ADK/temp/sendToAdapter/someFileToSend.dat


2. Replace sample_dataQ with Adapter_dataQ and replace someFileToSend.dat
with data.txt


Any login to do this with brief syntax is highly appreciated.

Thanks in advance

Anand