Awesome thanks all for reply . got it
regards irfan ________________________________ From: midhun <[email protected]> To: Rob Coops <[email protected]> Cc: Gergely Buday <[email protected]>; Irfan Sayed <[email protected]>; "[email protected]" <[email protected]> Sent: Thursday, August 16, 2012 2:41 PM Subject: Re: search and replace The issue is $cs_project = "C:\build.txt"; ## In Double quotes takes the string as C:build.txt.since its an escape character That's the reason why Rob suggested to put the string in Single quotes. Both Gergely and Rob are right. Cheers, Midhun On Thu, Aug 16, 2012 at 2:29 PM, Rob Coops <[email protected]> wrote: > On Thu, Aug 16, 2012 at 10:55 AM, Gergely Buday <[email protected]> wrote: > > > Here is the correct version: > > > > #!/usr/bin/perl > > > > $csproj_text = "C:\\build.txt"; > > > > $csproj_text =~ s/\\/\\\\/g; > > print "$csproj_text\n"; > > > > Notice that in order to put a literal backslash into a perl string, > > you should escape it. In your original program, you have put a \b, a > > bell character into the string. > > > > - Gergely > > > > On 16 August 2012 10:48, Irfan Sayed <[email protected]> wrote: > > > hi, > > > > > > i have following code to search single "\" and replace it with "\\" > > > but it is not doing as expected: > > > > > > $csproj_text = "C:\build.txt"; > > > > > > $csproj_text =~ s/\\/\\\\/g; > > > print "$csproj_text\n"; > > > > > > the output is : "Cuild.txt" > > > instead the output should be : "C:\\build.txt" > > > can someone please suggest, what is the wrong ? > > > > > > regards > > > irfan > > > > -- > > To unsubscribe, e-mail: [email protected] > > For additional commands, e-mail: [email protected] > > http://learn.perl.org/ > > > > > > > That or replace the " with ' and all wil be fine. > > $csproj_text = 'C:\build.txt'; > > $csproj_text =~ s/\\/\\\\/g; > print "$csproj_text\n"; > > Regards, > > Rob >
