will cause perl to complain (if you have not declared (and thus created) $foo before), while writing

Oh will it now?

$ perl -le " use warnings; use strict; my $foo; $foo++; print $foo " 1

So these two examples are not comparable. And I believe the second example actually is where we see autovivication at work.

Yes, they really are exactly comparable, and no, the second example is not autovivification any more than the first example is autovivification -- neither is autovivification

Growing an array is not autovivification. JavaScript doesn't support autovivification , try it if you have firefox ( Ctrl+Shift+K )

[03:41:08.755] var noauto = [ 0, 1 ]; noauto[ 6 ] = 66; noauto ; [03:41:08.764] [0, 1, , , , , 66] [03:43:06.834] noauto[2].failToAutoVivify = 12; noauto; [03:43:06.843] TypeError: noauto[2] is undefined

JavaScript supports growing arrays but not autovivification, but perl does supports it, undef becomes a hashref if you treat it like a hashref

$ perl -MData::Dump -le " my $auto = [ 0, 1 ]; $$auto[6]=66; dd $auto; + " [0, 1, undef, undef, undef, undef, 66] $ perl -MData::Dump -wle " my $auto = [ 0, 1 ]; $$auto[6]=66; $$auto[2 +]{VIVIFY}=12; dd $auto; " [0, 1, { VIVIFY => 12 }, undef, undef, undef, 66]

In reply to Re^4: Occurence List by Anonymous Monk
in thread Occurence List by Hopfi

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.