I was writing up some docs (in a perldoc-like style--we can always
change the form later, but the content is important), and started
working on documenting references.  I ended up with this bit:

*** BEGIN DOCS ***

=head3 Autovivification

Actually, one of the features of the extra-sigil mentioned earlier makes
this line of code unnecessary.  If you use the extra-sigil syntax and
the scalar used is C<undef>, it's automatically filled in with a
reference of the appropriate type.  This process is called
I<autovivification>.

So the first (incorrect) example can be fixed by just changing the
C<push> line to this:

        @{%anagrams{$key}}.push $word;

Autovivification also happens when you try to retrieve or set an element
of an array or hash reference, but the reference is C<undef>:

    $undefined_var[$idx]=$scalar;

*** END DOCS ***

Is this correct?  My rationale is that other classes could have a
C<push> method, so you can't infer just from the C<push> that you should
autovivify an array.

--Brent Dax <[EMAIL PROTECTED]>
@roles=map {"Parrot $_"} qw(embedding regexen Configure)

Wire telegraph is a kind of a very, very long cat. You pull his tail in
New York and his head is meowing in Los Angeles. And radio operates
exactly the same way. The only difference is that there is no cat.
    --Albert Einstein (explaining radio)

Reply via email to