gam3 has asked for the wisdom of the Perl Monks concerning the following question:

I was reading perlsec and saw the following:
# Regular expressions - Perl's regular expression engine is so called NFA (Non-Finite Automaton), which among other things means that it can rather easily consume large amounts of both time and space if the regular expression may match in several ways. Careful crafting of the regular expressions can help but quite often there really isn't much one can do (the book "Mastering Regular Expressions" is required reading, see perlfaq2). Running out of space manifests itself by Perl running out of memory.
So this notes how running out of space manifests itself in Perl, but does not say how running out of time is manifested in Perl. I am sure that there are some monks that would like to help me answer this question.
-- gam3
A picture is worth a thousand words, but takes 200K.

Replies are listed 'Best First'.
Re: Running out of time?
by blokhead (Monsignor) on Jan 28, 2007 at 21:34 UTC
    Processes have limited space available (limited by physical resources and memory-addressing issues), but generally unlimited time. You usually cannot "run out of" time, you can just "take more" time. The only thing I can think of is if the OS imposes a CPU time limit on the process. Exceeding the limit manifests itself by the OS killing the process.

    Also, this doc desparately needs to be patched: s/Non-Finite/Nondeterministic Finite/; "Non-finite" just makes me chuckle/cringe.

    blokhead

Re: Running out of time?
by shmem (Chancellor) on Jan 28, 2007 at 23:33 UTC
    To have perl running out of time, you have to mask it's builtin limit. The builtin limit is eternity. See alarm.

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
      Well actually we don't really know what the limit is because it's an undecidable problem :)

        The policemen said "Halt!", and Turing answered "I don't know".


        "There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.