Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Top 10 things I learned my 1st month as a Monk

by toolic (Bishop)
on Jul 18, 2007 at 17:47 UTC ( #627314=perlmeditation: print w/replies, xml ) Need Help??

or, Perl nuggets I absolutely, positively can no longer live without:

  • 9 ... A new acronym: STFW
    to complement an old favorite: RTFM
  • 8 ... use diagnostics;
    when use warnings; just isn't verbose enough
  • 7 ... __DATA__ (see perldata)
    You mean I don't need to create all those extra temporary input files after all?
  • 6 ... Data::Dumper
    I'm really gonna miss adding all those print statements to debug my code. NOT!
  • 5 ... Obfuscated camel code
    When I showed the output of the script to a co-worker, he said, "Wow! That's cool!", and when I told him to look at the contents of the script, he said, "It's a little hard to read though". I can't make this stuff up.
  • 4 ... Whitespace in a regular expression using the /x modifier
    m/\d+\w+/ is the same as m/ \d+ \w+ /x Who knew? PerlMonks, that's who!
  • 3 ... perldoc
    Not only is it a searchable website, but it's also a Unix-style manpage. It slices, it dices, it... Now I know what all that POD code is for!
  • 2 ... perltidy (see Perl::Tidy)
    and his side-kick xmltidy (see XML::Tidy). Imagine my surprise to find out that there are others out there as finicky as I am about coding style. Actually, "finicky" just doesn't quite describe it. More like obsessive-compulsive and completely paralyzed until I line up the curly braces and use consistent indentation in the code I inherited from some slovenly co-worker. Doesn't anyone care? Doesn't anyone have any self-respect? At least make it look like you know what you're doing (even if you don't)! ... Whew. Just had to get that off my chest. (Blood pressure dropping to normal levels now...)
  • 1 ... PM is a place I can expand my Perl skills
    I'm not a programmer. I don't really even work with programmers. But, I do enjoying hacking Perl every chance I get at work. So, to me, the Monastery is a nice intellectual sandbox where I can learn and be challenged.
  • 0 ... It feels good to finally give back
    Being able to help others by sharing my (limited) knowledge is truly satisfying. All right, all right, I'll admit that collecting XP is fun, too.
  • OK, so this is all blatantly obvious to masters of the Perl universe. But to those novices out there, just start using these techniques and you will enhance your life far beyond your wildest dreams. Well, that's a bit of an exaggeration, but you get the picture. As always, this is intended to help.

    Replies are listed 'Best First'.
    Re: Top 10 things I learned my 1st month as a Monk
    by CountZero (Bishop) on Jul 18, 2007 at 20:57 UTC
      If you liked Perl::Tidy, did you try Perl::Critic yet?

      CountZero

      A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

    Re: Top 10 things I learned my 1st month as a Monk
    by Gavin (Chancellor) on Jul 18, 2007 at 18:02 UTC
      What happened to use strict.
        use strict; is absolutley critical.

        I've been using it for years. This posting is not meant to be a comprehensive list of all the basic necessities. It is merely the most important things I learned since joining PM.

          Every time I see production code without those two words up the top, I die a little inside. We've been transitioning servers at work this week and today when writing a new script I found a mailer module that wasn't working as expected. The reason:
          my $Package = caller(); my $MailServer = eval "\$".$Package."::Settings{'MailServer'}";
          All the existing modules had %Settings declared as a global so it worked. Eurgh.
    Re: Top 10 things I learned my 1st month as a Monk
    by zentara (Archbishop) on Jul 19, 2007 at 11:56 UTC
      Don't forget laziness..... always search http://groups.google.com for existing code snippets. Usually someone has already worked out the best syntax for certain purposes, and posted it in the newsgroups.

      I'm not really a human, but I play one on earth. Cogito ergo sum a bum
    Thank you! (Re: Top 10 things I learned my 1st month as a Monk)
    by chaitins_omega (Initiate) on Jul 19, 2007 at 22:43 UTC
      I'm printing this out and tacking it to my drab, gray cubicle wall!
    Re: Top 10 things I learned my 1st month as a Monk
    by brusimm (Pilgrim) on Jul 24, 2007 at 16:31 UTC
      One must never forget the valuable, enforced lessons of asking the proper questions, learning to do your own research, and proper formatting of one's posts too!

      It's a logic learning site on top of all the Perl Wisdom!!

      Thank you Monks.

    Re: Top 10 things I learned my 1st month as a Monk
    by sundialsvc4 (Abbot) on Nov 15, 2010 at 13:31 UTC

      Since this thread has “resuscitated” by recent reference ... one thing that I didn’t initially grok, but that is very good to know, is that http://www.perldocs.org takes a few seconds to actually come up with the perldoc-page you have requested.   It displays a fairly-empty screen (suggesting, to the impatient, that somehow the document could not be found), then comes up with the goods a few seconds later.

    Re: Top 10 things I learned my 1st month as a Monk
    by Incorporeal (Initiate) on Jul 22, 2007 at 13:04 UTC
      use strict; was moreso just a learning curve for me - I have not written any code for months where strict has actually alerted me on anything. I don't see it as being absolutely critical unless you are a beginner who needs to learn better practices as they do not do them naturally.
        Is there some performance gain to not using strict? Otherwiese, even if you normally do everything in a strictly correct manner wouldn't it still make sense to use strict just in case you slip-up?
          Some of the strict checks are runtime checks. However, the overhead involved probably won't be noticed. If your program is so time-critical that strict pushes it past some limit, there's likely much better ways to get that time back. Removing strictness for performance seems like a very premature optimization.
        In that case you are probably not doing anything really new.

        use strict helps avoid surprises.

    Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Node Status?
    node history
    Node Type: perlmeditation [id://627314]
    Approved by lidden
    Front-paged by coreolyn
    help
    Chatterbox?
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others surveying the Monastery: (4)
    As of 2018-04-20 22:49 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Notices?