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

Here is an odd piece in deed. Apparently it is dependent on the actual names you are using in that they contain a _. I have no idea why but check this out.

C:\Perl\Tests>perl -c -e"$var = { aa...aaaa}" -e syntax OK C:\Perl\Tests>perl -c -e"$var = { aa...aaaa_}" C:\Perl\Tests>perl -c -e"$var = { 'aa'...'aaaa_'}" C:\Perl\Tests>

The last two had to be killed as they consumed all the processors power. The first flew through in no time, obviously not computing. So some little thing is causeing the _ to make it actualy execute that code.

BTW C:\Perl\Tests>perl -c -e"'aa'...'aaaa_'" without the hash ref doesn't cause any delay, and checks out perfectly.


___________
Eric Hodges

Replies are listed 'Best First'.
Re^4: Syntax error makes perl hang
by cfreak (Chaplain) on Aug 15, 2005 at 20:53 UTC

    I tried assigning it to an array and took out the '_':

    @foo = ('pfo' .. 'pctpfo' );

    This didn't work, in fact I let it run to see if it would eventually come up with something ... instead it took my machine with it (fun to cause a hard reboot in Linux every now and then right?). Anyway that makes me suspect there is some kind of memory leak.

    Oddly enough its not the length of the string: Using 'aaaaaaaaa' worked just fine so it must have to do something different when there are several different characters

      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\

        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

        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.

Re^4: Syntax error makes perl hang
by Tanktalus (Canon) on Aug 16, 2005 at 03:24 UTC

    It's not that the underscore is special, it's that the underscore is not special. Check for 'magic' in perlop. Only letters and numbers are magically incremented. All others are not. So, when you increment "aa" to "ab" then to "ac" and so on to "az", then "ba" to "bz" and so on to "zz", then to "aaa", etc., you will never reach "aaaa_". It's just not possible. But perl keeps on trying.

    Your last test evaluates in scalar context which then does not expand to a list. The .. and ... operators in scalar context work quite differently from list context.