Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2024-04-19 10:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found