in reply to Syntax error makes perl hang

Actualy you don't have a syntax error. Just a bit of unintended code. ;) I beleive perl is reading it like below..... It isn't hung, just taking a long time to compute all the combinations between pfo and pct_pfo which is a rather large number i'm guessing.

#!perl $rec = { avg_outst => pfo...pct_pfo, ' ', };

___________
Eric Hodges

Replies are listed 'Best First'.
Re^2: Syntax error makes perl hang
by VSarkiss (Monsignor) on Aug 15, 2005 at 20:30 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

        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.

      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

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

      /J\