Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: using a subroutine

by bgreenlee (Friar)
on Aug 08, 2004 at 22:23 UTC ( #381116=note: print w/replies, xml ) Need Help??


in reply to using a subroutine

Good start. Some suggestions:

  • Use 'my' when declaring your variables. Global variables are generally Not Good
  • Assuming those aren't the only two directories you'll ever want to process, consider passing in the directories on the command line, either directly through @ARGV, or via Getopt::Long (or Getopt::Std, if you're old-school)
  • Congrats on using -w...now use strict
  • in this program, there's really no reason to have the directories read by one subroutine and processed by another. A subroutine should generally be potentially useful to more than one caller. If it is only ever going to be called in one place, consider just moving it to that place (one exception to this "rule" is if you're breaking out significant chunks of code for increased clarity)

    Brad

  • Replies are listed 'Best First'.
    Re^2: using a subroutine
    by xjlittle (Beadle) on Aug 10, 2004 at 00:32 UTC
      Brad,
      your points are well taken. I will get into the habit of watching my my's and my ()'s.

      Thanks!
      John

    Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Domain Nodelet?
    Node Status?
    node history
    Node Type: note [id://381116]
    help
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others drinking their drinks and smoking their pipes about the Monastery: (2)
    As of 2023-09-23 21:50 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found

      Notices?