Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Comments, in no particular order:

  • Where's use strict; and use warnings;? To me, putting these in perl code is like avoiding goto: it's good advice, and you should heed the advice until you know why the advice is given and you know why the advice may not apply to your current effort. (Let's just say I use "goto" far more often, especially in C, than I purposefully avoid using strict and warnings.) Granted, if your code works, it's probably fine, but you may find that the perl compiler (and interpreter) can give valuable advice, especially during development of a new script, just by turning these on.
  • I don't see anything wrong with explicitly using $_. Avoid it when you can, and you remember, but don't fret if you don't remember. Far more functions work when $_ is explicit than when you leave it out. ;-)
  • Use glob instead of the <> operator when expanding shell-like expressions as on your second line.
  • Personally, I avoid the map and grep EXPR versons, and always use the BLOCK versions. Admittedly, the EXPR version may be faster in some (many?) cases, but not only does the BLOCK version work in all cases, but I just find it clearer (no mental parsing for commas)
  • Finally, I'd have renamed the files to $_ . "5.8" instead of $_ . ".5.8" (e.g., "perl5.8" instead of "perl.5.8"). I think that's a bit more standard. Actually, I would not have renamed the old perl's at all - your system may have OS tools that are dependent on the system perl that probably have not been tested with perl 5.10. If they break with the new perl, Apple likely won't give you support. Instead, I'd call the new perl "perl5.10" and then I can have my own scripts with the line "#!/usr/local/bin/perl5.10" at the top to get the perl I want.
As for a rating, your scale is difficult to work with ;-) I'd have to say that if it worked, the rating automatically is decent. The only caveat really is that last point: system tools may expect the system perl to be the one that the system installed. Playing with that is always dangerous. But that isn't a comment on your perl code, it's more a comment on your unix-fu :-)

(Congrats :->)


In reply to Re: My first USEFUL script! by Tanktalus
in thread My first USEFUL script! by nefigah

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 cooling their heels in the Monastery: (7)
As of 2024-04-23 14:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found