thanks a lot
regards irfan ________________________________ From: Shawn H Corey <[email protected]> To: [email protected] Cc: Irfan Sayed <[email protected]> Sent: Saturday, August 18, 2012 6:50 AM Subject: Re: search and replace On Fri, 17 Aug 2012 18:02:23 -0700 (PDT) Irfan Sayed <[email protected]> wrote: > i have string like this : > $a = '$(workspace)\convergence\trunk'; > > i need to replace $(workspace) with 'c:\p4\abc' > i wrote regex like this : > > $a =~ s/$\(workspace)/c:\\p4\\abc/; The easy way is to quote it: $a =~ s/\Q$(workspace)\E/c:\\p4\\abc/; or you could insert the escapes by hand: $a =~ s/\$\(workspace\)/c:\\p4\\abc/; And to make it more readable, use the /x switch to allow whitespace: my $base_dir = 'c:\p4\abc'; $a =~ s{ \$ \( workspace \) }{$base_dir}x; See `perdoc perlre` and search for: /\\Q/ under the 'Regular Expresions' section; and /\/x/ under the 'Modifiers' section. -- Just my 0.00000002 million dollars worth, Shawn Programming is as much about organization and communication as it is about coding. _Perl links_ official site : http://www.perl.org/ beginners' help : http://learn.perl.org/faq/beginners.html advance help : http://perlmonks.org/ documentation : http://perldoc.perl.org/ news : http://perlsphere.net/ repository : http://www.cpan.org/ blog : http://blogs.perl.org/ regional groups : http://www.pm.org/
