Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

If I may add an adjective to your canonical list, I'd like to present The Simple: if Perl has to go through (dereference) a reference to get to something, autovivification happens...

Yes, this is simple for the experienced programmer who is comfortable with the whole notion of references, but not so simple for the programmer who is just beginning to work with them. I know from helping newbies at work that references don't come easy to many people for some reason. And even in the best of cases, one first has to become sensitized to the possibility of autovivification-mediated trouble before one develops an eye for unintended autovivification. This is true for just about any class of bugs. (perlreftut, perlref, and perltrap need to do more towards alerting programmers to autovivification bugs.)

And even with a bit of experience, something like this:

my @good_ones = grep $_->stars == 5, @dvds{ qw( Ray Alexnader Sideways Catwoman Avia +tor ) };
can silently trip you. Or, while it's clear that
if ( exists $h{ wild_guess }->{ ssn } ) { ... }
is dereferencing, and hence autovivifying, $h{ wild_guess }, it is less clear (or at least it was so to me) that
keys %{ $h{ wild_guess } }
is also autovivifying $h{ wild_guess } even though apparently there is no dereferencing going on (if by "dereferencing" one means getting the value at a given address). That's why mMy version of your Simple is "any time that perl is asked to interpret an undef as if it were a hash ref (or array ref, or scalar ref), it will turn the undef into a ref to an empty hash (or empty array, or undef)."

Update: What am I saying?! Of course there is dereferencing in %{ $h{ wild_guess } }. So "asked to interpret an undef as if it were..." is just a wordier way to say "dereference". I confess that I find it more intuitive somehow, but I'd still say that your Simple is much simpler than mine.

Update: Added perltrap to the docs list above.

the lowliest monk

In reply to Re^2: The Bad, the Ugly, and the Good of autovivification by tlm
in thread The Bad, the Ugly, and the Good of autovivification by tlm

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    [Eily]: marto you just need a longer cable :P
    [Corion]: marto: Yeah, but I'm somewhat wary of installing random USB drivers downloaded from , Google Drive or whatever, so Linux wins there due to there being no conflicts and me just having to edit one text file in the worst case, to add the USB vendor
    [hippo]: Long USB cable FTW.
    [Corion]: Eily: I've thought of that, but I don't like running long cables through the appartment because sooner or later I'll trip over it, pulling at least one device off its stand :)
    [marto]: hmm, may have to patch CPAN::Meta to move from search.cpan to metacpan in the META.json/yml files
    [Corion]: marto: Heh - it seems that they plan to keep the links alive for a long time. But still, I plan on moving PM to use/generate the new links
    [Corion]: And I think it's better to generate links to the new world instead of keeping the older links alive by generating new versions of them ;)
    [marto]: yeah, I guess it's supposed to be a permanent redirect, but better to make the move where possible

    How do I use this? | Other CB clients
    Other Users?
    Others making s'mores by the fire in the courtyard of the Monastery: (12)
    As of 2018-05-23 09:18 GMT
    Find Nodes?
      Voting Booth?