in reply to Is this a bug in splice?

Are you referring to the lack of stricture errors? Quote perlvar,

Perl identifiers that begin with digits, control characters, or punctuation characters are exempt from the effects of the package declaration and are always forced to be in package main ; they are also exempt from strict 'vars' errors.

Replies are listed 'Best First'.
Re^2: Is this a bug in splice?
by Limbic~Region (Chancellor) on Feb 20, 2008 at 02:48 UTC
    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

      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