You've somehow successfully manipulated the array @$. I proved it by adding the following snippet of code:
for my $key (sort keys %main::) { next unless *{$main::{$key}}{ARRAY}; print "$key\n"; }
Before your splice, I found only +, -, ARGV, INC and _ populated. After your splice you added $. The last array was, of course, empty. But the following code clearly populates it:
#!/usr/bin/perl use strict; use warnings; my @list = map {[qw/foo bar blah baz/]} 1 .. 5; splice(@$, 0, 1, "hello", "world") for @list; print "@$\n";
Edit: Simplified my code. I knew there was an easier way to write @{*main::{'$'}{ARRAY}}...

Update: Upon thinking about it, this behaviour likely falls out of whatever logic makes $$ be recognized as a valid variable name. Because if you can name a variable $, then you should be able to put any sigil you want in front of that $. Or dereference it any way you want.

This is one of the astounding things about Perl. You start with a piece of behaviour and you say, "WTF?" Then you figure out what it did and you say, "Oh, here is what it did." Then you figure out why it did it and you go, "Oh, that is really quite reasonable for it to do." And suddenly it doesn't seem all that surprising.


In reply to Re: Is this a bug in splice? by tilly
in thread Is this a bug in splice? by Limbic~Region

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.