in reply to Re^2: PERL Variable Name, Significant length
in thread PERL Variable Name, Significant length
Oh my, you appear to be correct.
The parser seems to have a hardcoded limitation of 256 characters. This runs fine:
C:\test>perl -E"$xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx1 = 1"
But add 1 more x and it stops with:
C:\test>perl -E"$xxxxxxxxxxxxxxxxx Identifier too long at -e line 1.
or just traps or both. But the limitation (static buffer or hardcoded length?) is only in the parser, the rest of perl handles longer fine. What I did to verify my assertion above (before making it) was:
$longName = 'x' x 1e4;; ${ $longName . 1 } = 1;; ${ $longName . 2 } = 2;; if( ${ $longName . 1 } != ${ $longName . 2 } ) { print 'Great! Ten thousand characters long and all significant.' };; Great! Ten thousand characters long and all significant.
I knew there was some limitation, because when I tried for a hundred thousand(*) it bellyached about something being readonly. But as far as I'm concerned, 10,000 is for all practical purposes, unlimited.
I've encountered one or two authors that insisted in detailing their life, work or academic career histories into their comments; but never a novella in a variable name :)
(*)Update: Or maybe I just typoed because I've now succeeded in creating variable with a million (and one) significant characters...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: PERL Variable Name, Significant length
by morgon (Priest) on Aug 07, 2009 at 23:38 UTC | |
by BrowserUk (Patriarch) on Aug 08, 2009 at 00:42 UTC | |
by morgon (Priest) on Aug 08, 2009 at 01:00 UTC | |
by BrowserUk (Patriarch) on Aug 08, 2009 at 01:52 UTC |