Do you know where your variables are? | |
PerlMonks |
Re: Currency symbols in variable namesby davido (Cardinal) |
on Aug 26, 2019 at 05:48 UTC ( [id://11105036]=note: print w/replies, xml ) | Need Help?? |
A simplistic view of what constitutes a legitimate identifier is any name that matches the following regexp:
But this has many shortcomings, some of which are described in a StackOverflow article from tchrist (When I read his articles dealing with Unicode I mostly just feel small). It doesn't allow for most punctuation variables described in perlvar, for example... but even discounting those, it's just a start. I mention this because the symbols you are using in your identifier will not match that regular expression, despite ID_Start and XID_Continue matching well over a hundred thousand characters. And these aren't punctuation characters described in perlvar either. So for typical use you can probably disqualify them outright. One thing of note is that when wielding symbolic refs, nearly any set of characters is legal, including your currency symbols. Case in point:
Spoiler alert, it works. And notice we're using the £ and ¥ characters. Symbol manipulation is something Perl is good at, but that we try to avoid for our own sanity. A language that more fully embraces it is Scheme. And since symbol manipulation is the name of the game for Scheme, naturally that language is fine with ¥ as a function identifier:
Dave
In Section
Seekers of Perl Wisdom
|
|