>>>>> "TS" == Tolkin, Steve <[EMAIL PROTECTED]> writes:

  TS> # run using e.g. echo hello | perl this-file
  TS> # Why doesn't perl produce a warning from the following.  It is an
  TS> # infinite loop.  If I add a /g modifier to the m// it works fine.

  TS> while (<>) {
  TS>     while (m/([a-z])/) { # warning infinite loop!!! 
  TS>         print $1, "\n"
  TS>     }
  TS> }
    
if perl could figure out that is an infinite loop, it could also solve
the halting problem. what if the body optionally modified $_ so the m///
failed? how would perl know that is ok but your code is not?

  TS> ///  

  TS> In general it is hard to detect infinite loops, but in this case
  TS> it is easy, because the pattern is a constant.  I think this is a
  TS> very common special case, and is worth detecting.

but the data isn't a constant.

  TS> Why isn't this done?

because it can't be done?

uri

-- 
Uri Guttman  ------  [EMAIL PROTECTED]  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org
_______________________________________________
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to