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

I think you're on the right track, as are the others in this thread who noted that ... is a range operator. But the question still is, why does it not even compile? I can understand it taking forever to execute, but not even perl -c or B::Deparse return. The code's not in a BEGIN block or any such.

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

    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

      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\

      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.

Re^3: Syntax error makes perl hang
by Transient (Hermit) on Aug 15, 2005 at 20:38 UTC
    To add to the detective work, changing to
    #!/usr/bin/perl $rec = { avg_outst => pct_pf... # BAD pct_pfo => ' ', };
    gives me
    C:\Perl>perl -MO=Deparse testhang.pl $rec = {'avg_outst', 'pct_pf', ' '}; testhang.pl syntax OK
Re^3: Syntax error makes perl hang
by gellyfish (Monsignor) on Aug 15, 2005 at 20:35 UTC

    At a guess it is trying to create the result list at compile time.

    /J\