Is there any way you can provide your data file? If it's very large, put it on your scratchpad rather than here. Also, please give the "long error message" you are getting so I can try to see what's going on.

It looks like you're using a LOT of global variables. This can be bad, as you may inadvertently change the global in another function. Instead, try passing variables between your subroutines and declaring scopes by using my. Also, some more code efficiency:

1. You can avoid using a bunch of escape characters by using alternative characters for your regexes. It will sometimes look cleaner and be much easier to see what it is you're trying to do.

$dest =~ s/\//\\/g; # Rewritten: $dest =~ s#/#\\#g; # Singular character $dest =~ s{/}{\\}g; # Paired characters

There are a bunch of other characters you can use here. Don't worry, the # won't be seen as a comment.

2. Don't bother making a copy of an array before sorting it. The sort function will return the sorted array without changing the original.

@sortedarraydirectory = @arraydirectory; @sortedarraydirectory = sort @sortedarraydirectory # Change to 1 command: @sortedarraydirectory = sort @arraydirectory;

I also learned Perl on my own, with some limited help from a guy at work (heck, I'm still learning it!). I highly suggest you look into O'Reilly's Learning Perl, as it's a very well-written resource that will teach you the essentials. Progamming Perl is also a valuable resource, but moreso after you are already familiar with the language.


In reply to Re^5: Duplicates in Win32::DirSize by wink
in thread Duplicates in Win32::DirSize by Real Perl

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.