Hi Al, Thanks a lot!! I have been able to solve my problem and have also learnt a lot from all these inputs.
Thanks once again. Parvez -- --------- Original Message --------- DATE: Thu, 18 Mar 2004 08:02:41 From: "Elston, Jeremy" <[EMAIL PROTECTED]> To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]> Cc: >Greetings... > >If it helps, greedy matching is more akin to the following. Let us say that >you always wanted to change the first word (in this case 'var') with 'foo'. >Perhaps writing this code to do it: > $str =~ s#/.*/#/foo/#; # Avoid LTS (leaning toothpick syndrome) > >This is where greedy comes into play. Instead of just matching "/var/", the >first successful match, Perl will get greedy and match "/var/tmp/test/". We >wanted "/foo/tmp/test/stuff", but instead we ended up with "/foo/stuff". > >Hope that helps. > > >Jeremy Elston >Sr. Staff Unix System Administrator >Charles Schwab & Co., Inc. > >"The Jim Conspiracy IS real! You will be assimilated!" >http://www.geekcode.com >-----BEGIN GEEK CODE BLOCK----- >Version: 3.1 >GCS d? s a? C++++ US+++ P++++$ L+> E--- W+$ N+ >o K w+ O- M> V-- PS@ PE Y+ PGP t 5++ X@ R@ tv+ >b+++@ DI++++ D+ G e* h-- r- z* >------END GEEK CODE BLOCK------ >WARNING: All email sent to this address will be received by the Charles >Schwab Corporate email system and is subject to archival and review by >someone other than the recipient > > > >-----Original Message----- >From: Parvez Pathan [mailto:[EMAIL PROTECTED] >Sent: Wednesday, March 17, 2004 10:00 PM >To: perllist >Subject: [Perl-unix-users] Greedy Matching > > > >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 > ____________________________________________________________ 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