Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: How Perl decides where a variable ends and text starts: Match variables in string interpolation

by LanX (Sage)
on Jul 22, 2021 at 23:00 UTC ( #11135320=note: print w/replies, xml ) Need Help??


in reply to How Perl decides where a variable ends and text starts: Match variables in string interpolation

Hi

I'm pretty sure "regular" $identifiers can't start with a digit, so something like $1_ can't be legal anyway

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

  • Comment on Re: How Perl decides where a variable ends and text starts: Match variables in string interpolation
  • Download Code

Replies are listed 'Best First'.
Re^2: How Perl decides where a variable ends and text starts: Match variables in string interpolation
by BillKSmith (Prior) on Jul 23, 2021 at 00:49 UTC
    I was almost certain that I had seen a counter-example, but you are right Variable names.
    Bill

      There are symbolic refs, but you have to stay in the symbolic ref world. If you create ${'1_'} as a symbolic reference, you have to continue to refer to it symbolically only. Perl barfs if you try to use it as $1_ later on. Here's a working example, though:

      { no strict 'refs'; ${'1_'} = 100; print ${'1_'}, "\n"; }

      If you go on to dump the %main:: hash you'll see the package global $1_ does exist. Perl's syntax just doesn't support it as anything but a symbolic ref, I think.


      Dave

        A more extreme example:

        Win8 Strawberry 5.8.9.5 (32) Fri 07/23/2021 20:17:49 C:\@Work\Perl\monks >perl -Mstrict -Mwarnings -l { no strict 'refs'; ${'@-%^#$!+'} = 'Yikes!'; print ${'@-%^#$!+'}; } print "%main:: $main::{'@-%^#$!+'}"; ^Z Yikes! %main:: *main::@-%^#$!+
        Same behavior under Strawberry 5.30.3.1 64-bit.


        Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11135320]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2021-09-27 21:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?