Link to home
Start Free TrialLog in
Avatar of shahrahulb
shahrahulb

asked on

replace

i have a file temp.txt which has a line
ENVELOPE = "hkdscj@ljld.com";

in my perl script;send-multi.pl
my $user = "rshah1\@yahoo.com";
`perl -i -wpe 's/ENVELOPE = ".*"/ENVELOPE = "$user"/g' send-multi.pl`;


i want to replace hkdscj@ljld.com with rshah1\@yahoo.com
Avatar of ozo
ozo
Flag of United States of America image

my $user = "rshah1\@yahoo.com";
{local @ARGV=("temp.txt"); local $^I='';
  while( <> ){
     s/ENVELOPE = ".*?"/ENVELOPE = "$user"/g;
     print;
  }
}
Avatar of shahrahulb
shahrahulb

ASKER

not working
or just run from the command line:

perl -i -pe 's/ENVELOPE = ".*?"/ENVELOPE = "rshah1\@yahoo.com"/g' temp.txt



Is
ENVELOPE = "hkdscj@ljld.com";
The exact line in temp.txt?
Could those spaces be tabs?
s/(ENVELOPE\s*=\s*)".*?"/$1"rshah1\@yahoo.com"/g
>`perl -i -wpe 's/ENVELOPE = ".*"/ENVELOPE = "$user"/g' send-multi.pl`;

Do you want to change the entry in temp.txt or send-multi.pl??

in send-multi.pl

in my perl script;send-multi.pl
my $user = "rshah1\@yahoo.com";
`perl -i -wpe 's/ENVELOPE = ".*"/ENVELOPE = "$user"/g' send-multi.pl`;

this is not working
you say that ENVELOPE line is contained in temp.txt?? or is it in send-multi.pl??

Apologies, but im getting slightly confused by what you require

Manav
i m really sorry, its my fault.

my script temp.pl has the following 2 statements
my $user = "rshah1\@yahoo.com";
`perl -i -wpe 's/ENVELOPE = ".*"/ENVELOPE = "$user"/g' send-multi.pl`;

and envelope is in send-multi.pl

Are you running this on a Windows or a Unix OS??
unix
ASKER CERTIFIED SOLUTION
Avatar of manav_mathur
manav_mathur

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
awesome!!!!!!!!!!!!!!!
what does \Q and \E do
They will quote all metacharacters occuring between the \Q and the \E

thx :-)