in reply to Re: Is this a bug in splice?
in thread Is this a bug in splice?

tilly,
The frustrating thing is that you can't intentionally create @$ without some effort:
my @$ = 1..4; # issues an error
On the other hand, if you accidentally use it without declaration - it springs into existence and doesn't throw any errors nor warnings. Even if that is documented behavior, it smells bad (of course, there is probably very good reason for it).

Cheers - L~R

Replies are listed 'Best First'.
Re^3: Is this a bug in splice?
by tilly (Archbishop) on Feb 20, 2008 at 03:27 UTC
    Take a look at the error you get. Perl knows that @$ is not a valid name for a lexical variable. So it won't let you declare it with my. But it is a valid global variable name, and Perl recognizes it as such.

    Try declaring it with our. Also see my update to my original response.

    Edit: I said $@ and meant @$. Thanks ysth.

      tilly,
      I understand that and that this is documented behavior. I still don't like it.

      Perhaps it is because it is the first time I can remember getting bit by it. In a nutshell, perl is telling you that if you want to use a variable that starts with a punctuation character - you are on your own (no warnings/errors) so don't make a mistake.

      Cheers - L~R