http://qs1969.pair.com?node_id=578714


in reply to If I was forced to program in another language, the Perl language feature I would miss most would be:

Actually, the big one for me that's missing is autovivification.

The other day I had a list of co-ordinates (pulled from a DB as a record set). To put them into a grid, I simply did this:
my @grid; foreach my $rec (@records) { $grid[$rec->{x}][$rec->{y}] = $rec; }
That would've been a lot harder in most other languages.
  • Comment on Re: If I was forced to program in another language, the Perl language feature I would miss most would be:
  • Download Code

Replies are listed 'Best First'.
Re^2: If I was forced to program in another language, the Perl language feature I would miss most would be:
by ikegami (Patriarch) on Oct 17, 2006 at 15:24 UTC

    Adding

    grow(grid, $rec->{x}); grow(grid[$rec->{x}], $rec->{y});

    is not that complicated. Personally, I wish auto-vivification was off by default, and togglable using a lexical pragma.

Re^2: If I was forced to program in another language, the Perl language feature I would miss most would be:
by jgamble (Pilgrim) on Oct 17, 2006 at 18:55 UTC

    I probably wouldn't have voted for autoviv if it were on the list, but the one time I needed it (as opposed to "cute, but wasn't necessary") it saved me the bother of writing a whole other subroutine. So yeah, can be very useful.