Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Numeric Line Labels

Status
Not open for further replies.

CJason

Programmer
Oct 13, 2004
223
0
0
US
Is it true that you can't have a line label that starts with a number??? If so, why would that be a restriction!???!
 
What is a line label?

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
No, I never use them either. It's when you name a line with the name: construct for loop control and for those who like that sort of thing, goto. In the Perl doc labels are always shown as upper case, but I don't know if that's actually a restriction.

I guess Perl has rules about the kind of stuff it has in its symbol table and namespaces, and they can't start with numerics. It's quite a common restriction in many languages. If it's a problem for your code converter, can't you just stick a hard coded literal ('X' springs to mind) on the front?

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
ahh, those labels. Its ture you can't use a number, probably because in perl numbers don't have to be quoted:

$foo = 1;

So I suspect a construct like this would be seen as a syntax error.

1:

Labels are a must if you have embedded loops, the perl style guide encourages perl coders to use them.




------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
The Programming Perl bible by Larry Wall et. al. learns us (p 114)
If present, the label consists of an identifier followed by a colon. It's customary to make the label uppercase to avoid potential confusion with reserved words, and so it stands out better. And although Perl won't get confused if you use a label that already has a meaning like if or open, your readers might
combined with (p49)
An identifier is a token that starts with a letter or underscore and contains only letters, digits and underscores
we may conclude that digits are not allowed as the first character of an identifier, including labels.

_________________________________
In theory, there is no difference between theory and practice. In practice, there is. [attributed to Yogi Berra]
 
Thanks guys. I kind of combined all these posts and tacked on an "_" before the line labels that are causing the problems.

Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top