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

ikegami,
Ok, so perl thinks I have an array named @$

This is still frustrating because if I had done

my @$ = 1..4;
I would have gotten an error. This behavior still doesn't smell right to me but "oh well".

Cheers - L~R

Replies are listed 'Best First'.
Re^3: Is this a bug in splice?
by ikegami (Patriarch) on Feb 20, 2008 at 04:36 UTC

    Yes, but for unrelated reasons.
    @$ is not a valid name for a lexical.
    our @$ = 1..4; would not give an error.
    By your logic, splice(@Foo::bar, 0, 1) should give an error because my @Foo::bar = 1..4; gives an error.

      ikegami,
      No. That's not what I meant at all and I admit that my argument was not complete. What I am saying is that you are not forced to declare @$ with my nor our because it starts with a punctuation character. If I had declared it with my, I would have realized my typo because I would have gotten an error. If I had declared it with our, I would have meant to create a global variable.

      In other words, I understand that this is documented behavior but I don't like it. In a nutshell, if you make typos with variables starting with punctuation characters - you are on your own because they will silently spring into existance. I do really appreciate your response though because I was not parsing it the same way as perl which made even less sense :-)

      Cheers - L~R