Thanks for posting. I have two minor suggestions, if you are interested at all.

sub GetFile2 ... sub isAbsPath

If you don't want your users/co-developers to pull their hair out and curse your name into the void for eternity, don't arbitrarily capitalise the first letter of your sub names. Pick a format (any format) and stick to it.

sub isAbsPath { @_ or return 0; my $P = shift; defined $P or return 0; length($P) or return 0; $P = uc(substr(Trim($P), 0, 3)); my $c = vec($P, 0, 8); return 1 if ($c == 47 || $c == 92); return 0 if ($c < 65 || $c > 90); return 0 if (vec($P, 1, 8) != 58); $c = vec($P, 2, 8); return 1 if ($c == 47 || $c == 92); return 0; }

Did you know that perl has regular expressions? That will save all this hard-coding of ord values, etc. eg:

sub isAbsPath { my $path = shift; return 0 unless defined $path; return $path =~ /^([A-Z]:|[\/\\])/ ? 1 : 0; }

You could omit the ternary if you're only interested in a true/false return value. I've only demonstrated this one subroutine but many others could benefit from such simplification.

The alternative is to use a module. For this case, eg is_absolute from Path::Tiny.

The more you code in Perl, the more Perlish your code will become. Enjoy the journey.


In reply to Re^2: perl script to compare two directories by hippo
in thread perl script to compare two directories by harangzsolt33

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.