See the below code. It give you the correct output.
#!/usr/bin/perl my $str = "/var/tmp/test/stuff"; ## replace 'test/stuff' to 'test_stuff' ## $str =~ s/\//\_/; $str =~ s/test\/stuff/test_stuff/; print $str,"\n"; Regards C.M +++++++++++++++++++++++++++++++++++++++ Statutory Reporting IT, CBTO Deutsche Securities Limited [/], Tokyo Work +81-3-5156-7567 Fax +81-3-5156-6023 +++++++++++++++++++++++++++++++++++++++ [EMAIL PROTECTED] Sent by: To: [EMAIL PROTECTED] [EMAIL PROTECTED] cc: veState.com Subject: [Perl-unix-users] Greedy Matching 03/18/04 01:59 PM Please respond to parvezp Hi All, I am having a small doubt with the greedy pattern matching of Perl. We all know that Perl will try to match as many times as it can. But I am not getting the correct results. Please let me know if I am making a mistake. <CODE> my $str = "/var/tmp/test/stuff"; ## replace 'test/stuff' to 'test_stuff' $str =~ s/\//\_/; print $str,"\n"; </CODE> But this gives me the result as "_var/tmp/test/stuff" Can anybody tell me what is wrong? Regards, Parvez ____________________________________________________________ Find what you are looking for with the Lycos Yellow Pages http://r.lycos.com/r/yp_emailfooter/http://yellowpages.lycos.com/default.asp?SRC=lycos10 _______________________________________________ Perl-Unix-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs -- This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. _______________________________________________ Perl-Unix-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs