As I make my daily treks to the gates to learn/help where I can, I have noticed something...The majority of perl users/developers use perl for about everything except what the language letters stand for Practical Extraction and Reporting Language. We have entire websites run by perl, database applications, automation sequences, obfuscation , data munging, whatever.. I say all of that to bring this thought...Because Perl is so flexible, and can do just about anything we need it to, and a lot of us are most comfortable when coding in perl, does it necessarily make perl the end-all-be-all language. What forces us to NOT use perl? Another note I have is this...many of us have 'standard' stuff that we do everyday in perl, or a standard way of reading in files, or doing this or doing that, and some of it is probably a LOT more efficient than the way that I currently do stuff...and it is stuff that you can't necessarily put in a 'module' to share with the world, its just part of your coding nature.. So as to not open flame wars, or pandora's box, or anyother bad nasty thing...I thought maybe we could share with each other our 'best practices'..Obviously this couldn't be done at the language level, otherwise it would get really hairy, and wouldn't be of much use... So how about data munging...

take me for example...when reading in a fixed width file, I ALWAYS use pack and unpack instead of substr...why? because substr is SLOW, and I can parse the entire record at once instead of one field at a time.


When tie'ing hashes to a file with DB_File, I always use $DB_BTREE instead of $DB_HASH, because the search time to hit the hash seems to be faster when dealing with multi-million record files. I could be totally wrong and not know it too..

what else...
is for faster than foreach? dunno, never benchmarked it...anyone know?
is
my $num_elements=@array;
fasther than

my $num_elements=$#array;


As you can see I am looking for simple stuff here...nothing funky that is hard to interpret, just perl basics that we take forgranted sometimes in thinking that everyone knows about them.


Thanks in advance Robert

In reply to Reporting by krazken

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.