Perlish means taking advantage of perl control structures, data types, and abstractions. It means familiar to someone whose sole language is perl. That some of these perlish constructs look identical to constructs from other languages is not a problem. In fact, I'm sure that most of these constructs were stolen from those other languages anyway.

Abstractions such as using:

@hash{@a} = @b;
instead of:
for (my $i = 0; $i <= $#a; ++$i) { $hash{$a[$i]} = $b[$i]; }
are not only much clearer and cleaner, they probably run faster, too. Perl can pre-allocate a full hash of the right size, meaning only a single allocation. It can really get in there, optimising speed and space, which the C-style code cannot do. In C-land, one would have to do all those optimisations by hand: you'd need an array object which kept track of the length (because counting the array to find the length takes too long for large arrays); you'd need a hash object which could be told to pre-allocate a certain amount of space; you'd need to also remember each time you go populate the hash to pre-allocate the amount of space you need to keep re-allocations to a minimum.

In perl, all that extra overhead is handled for you. If you follow the perl idiom.


In reply to Perl idioms (was Re^2: Combining two lists into a hash) by Tanktalus
in thread Combining two lists into a hash by fthiess

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.