Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
# predeclare subroutines so subs; can be called before being declared # and without ()
subroutines don't have to be declared before you can use them in your code. The don't even have to be declared at compile time. If you are using AUTOLOAD the don't even have to defined when the are executed at runtime.
Also, learning the power of regular expressions will make your code more tighty. The following one line could replace your code that follows
# one line to make sure there is one and only one "/" $target_dir=~s<^/*></>;
Could replace all this:
#get first character in target_dir my $first_char = substr( $target_dir, 0, 1 ); writeLog( "debug - first character in target_dir $target_dir = $first +_char" ) if ( $debug ); if ( $first_char ne '/' ) { writeLog( "debug - adding / to beginning of target_dir $target_dir" +) if ( $debug ); #add "/" to beginning of filepath $target_dir = '/'.$target_dir; } else { writeLog( "debug - / already exists at beginning. target_dir remains + $target_dir" ) if ( $debug ); } #beginning has already been checked for "/" so check for addl # "/"s at position 1 ( ///IN/CF/ becomes /IN/CF/ ) #if position 1 is "/" chop it out and continue until position #1 is not a "/" writeLog( "debug - checking for multiple '/'s at beginning of target +dir $target_dir" ) if ( $debug ); my $second_char = substr( $target_dir, 1, 1); writeLog( "debug - initial second character in target_dir $target_dir + = $second_char" ) if ( $debug ); while ( substr( $target_dir, 1, 1) eq '/' ) { writeLog( "debug - removing / from second character in target_dir $t +arget_dir" ) if ( $debug ); chop( substr( $target_dir, 1, 1 ) ); writeLog( "debug - target_dir = $target_dir" ) if ( $debug ); }
Also your code has some many comments it makes it hard to read.
#verify that file exists checkFileExists() if ( ! $interactive );
If your function name is almost exactly the same as your comment, you probably don't need the comment

In reply to Re: Seek Critique of SFTP program, format, structure, overall "Perl"ness by fletcher_the_dog
in thread Seek Critique of SFTP program, format, structure, overall "Perl"ness by mikedshelton

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 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? | Other CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2022-10-05 18:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred way to holiday/vacation is:











    Results (24 votes). Check out past polls.

    Notices?