Pant, Hridyesh am Dienstag, 25. Oktober 2005 11.04:
> But the same is working if I am using
> orgtext="Hello";
> newtext="world";
> I tired $intext =~ s/$orgtext/$newtext/ms; but this is not working..
> The only problem is string like "C:\\test".

I was not well prepared with my last answer.

First, the combination of 
m: Treat string as multiple lines
and
s: Treat string as single line
is still contradictory.

But your problem comes from the string 'C:\\test' containing backslashes.

When you say f.e.
        my $str="C:\\test\a\b";

you get 'C:\test' in $str because of the double quotes the backslashes get 
interpolated. See perldoc perlop.

So, use single quotes.


Then, in your regex, use \Q and \E to disable pattern metacharacters. See 
perldoc perlre.

$orgtext='C:\\test';
$intext =~ s/\Q$orgtext\E/$newtext/gs; 
        

Joe


> -----Original Message-----
> From: John Doe [mailto:[EMAIL PROTECTED]
> Sent: 25 October 2005 14:08
> To: beginners@perl.org
> Subject: Re: extract zip file
>
> Pant, Hridyesh am Dienstag, 25. Oktober 2005 08.08:
> > Thanks..
> > Now I want to change the string in file.
> > orgtext="C:\\test";
> > newtext="/bin/old";
> > I tired $intext =~ s/$orgtext/$newtext/ms; but this is not working..
>
> Wrong modifiers /ms. See
>
> perldoc perlre
> perldoc perlretut
>
> joe
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to