in reply to Re^4: Syntax error makes perl hang
in thread Syntax error makes perl hang

Just try:

perl -e "@foo = ('pfo' .. 'pct'); print @foo"
and I think you'll start to get the picture. It's not az memory leak - it's just you are building a ridiculously large array.

/J\

Replies are listed 'Best First'.
Re^6: Syntax error makes perl hang
by eric256 (Parson) on Aug 15, 2005 at 22:06 UTC

    Sure. The question is, why is it building the array during a -c check? I guess if perl sees that neither the start nor the end can vary, then it does it at compile time, otherwise it differs it to runtime. That feels weird to me, and obviously to a few others as well. Although further checking shows that it is at least consitent, and not dependent on what charactes are use (which is what i thought before).


    ___________
    Eric Hodges
Re^6: Syntax error makes perl hang
by cfreak (Chaplain) on Aug 16, 2005 at 14:07 UTC

    Except that 'aa' ..'aaaaaaaa' which works is a bigger array than 'pfo' .. 'pctpfo', unless I'm completely misunderstanding how it increments them. I'm guessing there is some kind of optimization in that case? ... Either way why does Perl still allocate the memory during the -c check? (my machine crashed while using -c)

    If it is just the size I suppose there's not a bug per se, but it would be nice if there was some kind of brake to keep Perl from running away with all the memory. I still say there is a bug though, at the very least -c shouldn't allocate the memory.

      perl attempts some basic optimisations during the compile phase. One of which is to precalculate constant lists. Since both arguments to the range operator are constant the list it produces will be constant and can be precomputed.

      Well I was going to try this out and give some actual figures, but when I got to 'pfo' .. 'pctpf' it swallowed all the swap and I decided to reboot rather than wait for it. 'aa' .. 'aaaaa' was fine - producing 475229 elements.

      /J\