On May 4, 2004, at 1:40 PM, Madhu Reddy wrote:
Gary,
Close, but not quite. Glance at that name again. ;)
Thanks for your response.. those variables are only one for file..
say file1 have only <ABC_IFILE> and file 2 have only <ASD_IFILE>
like this i have 100 files...
i want a common search and replace to replace <*_IFILE> with new value..
i have common one like <IMPORT_IFILE> in all the files, for this i am doing following
s/<IMPORT_IFILE>/$in_out_file_path/ if (m/<IMPORT_IFILE>/);
The "if m/.../" part isn't needed and it's slowing things down. I suggest removing it.
similarly, i want to replace following this with
<ABC_IFILE> <ASD_IFILE>
new value..
I don't want to use following
s/<ABC_IFILE>/$in_out_file_path/ if (m/<ABC_IFILE>/);
s/<ASD_IFILE>/$in_out_file_path/ if (m/<ASD_IFILE>/);
because here ABC, ASD will change each time.. inly "_IFILE>" is fixed and common for all..
How to replace this ?
Did you read my last answer? I did cover this.
Step 1 - Load a hash:
my %replacements = ( ABC => 'ABC replace', ASD => 'ASD replace' );
Step 2 - Search and replace by key:
s/<([A-Z]+)_IFILE>/$replacements{$1}/;
James
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>