>>>>> "J" == Jatin  <daveyja...@gmail.com> writes:

  J> On Saturday 30 October 2010 01:11 PM, Uri Guttman wrote:
  >> 
  >> yes. infinite loop.
  >> 
  >> why did you remove the modifiers?
  J> [Jatin] I read about the perl regexp engine. In one of the statement i
  J> read that the engine stops matching once the pattern is found. so i
  J> had removed the modifiers and test if the engine stops and gives me
  J> the result as soon as the first match for the string "Perl" is found
  J> in my web page.

but you missed the important point. the engine will stop but the next
time through the loop it will START at the beginning of the
string. hence the infinite loop.

  >> do you know what the /g modifier does?
  >> 
  J> [Jatin] yes i know its functionality. It basically does not stop if
  J> the first match is found. It continues until all the matches are found
  J> in the string. In this case the string is stored in the $catalog
  J> variable.

wrong. in this case in scalar context, it does stop after a match. the
difference is that the starting point for the NEXT loop will be after
the match. so it will keep matching until the end of the string. hence,
it will always stop and no infinite loop.

  J> [Jatin] I would like to know , Critical in what sense ? I mean what
  J> makes it critcal ?

what i said above. you have read about /g in list context, but not in
scalar context. read the docs again and carefully look for the context.

uri

-- 
Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to