http://www.perlmonks.org?node_id=201742


in reply to search, replace and backrefrences

Well, im not real sure that $1_0_0_ isnt being treated as such.

But a useful trick in this situation and others is to use the form ${varname} to delimit the the identifier. Ie

my $foo="Groove"; print "$food"; # Error $food is not a declared indentifier. print "${foo}d"; # same as $foo."d";
So the rhs of the first and second could be ${1}0_0$2 and ${1}_0_0_$2 respectively.

--- demerphq
my friends call me, usually because I'm late....

Replies are listed 'Best First'.
Re: Re: search, replace and backrefrences
by rir (Vicar) on Sep 30, 2002 at 16:52 UTC
    Well, im not real sure that $1_0_0_ isnt being treated as such.

    Variable names that start with a digit may only have
    more digits in the name.

    This seems a murky area. my $99; throws an error.

    This post has little to do with the original question.

      Even with the number formatting semantics where 1_000_000 == 1000000?

        Even with the number formatting semantics where 1_000_000 == 1000000?

        Yes this use of underscores is only for numeric literals.

      Variable names that start with a digit may only have more digits in the name.

      Cool. I didnt know that. What perldoc is it in?

      This seems a murky area. my $99; throws an error.

      Well, i agree its weird, but its not that murky. All of the ^\d+$ variables are global only and cannot be my()ed (and all of the scalars are read only).

      --- demerphq
      my friends call me, usually because I'm late....

        I was about to say murky, but unimportant but bit my tongue
        as everything is important to someone.

        It seems unclear what behavior is intended, i.e. murky.
        Why shouldn't I be able to my $99;?   I haven't seen anything to
        suggest it is illegal. Or why is $123456 read-only?

        Is this documented somewhere? Point me at it.

        I'm pretty sure I got that from the Camel book.