Hi, This is my first time using perl, I've written a script that uses File::find to gather all directories in a tree and store them to file, then a hash. Each time the script runs it compares the current structure with the prior structure and makes the two hashes values at created/deleted. The directory name is the hash key btw. I'm trying to reduce excess results I get when there has been a directory name changed with multiple subdirectories. Can I use a regex to do this?
i.e. previous run C:\1\2\3\4 C:\1\2\3 C:\1\2 current run C:\1\x\3\4 C:\1\x\3 C:\1\x
At the moment this would generate 3 directories created and 3 deleted. I'd like it to be able to tell that just x may have been renamed or moved, including all its sub directories.
foreach $node (keys(%current)) { if ($current{$node} eq "created") { foreach $node2 (keys(%prior)) { foreach ($node2 =~ m/\/.+(\S)/) { if (($node =~ m/\/.+(\S)/) eq ($1)) { ($current{$node} = "unknown"), ($prior{$node2} = undef) +; }}}}}
That's some code that really doesn't work but might give you an idea of what i'm trying to do. Cheers.

In reply to Comparing strings to reduce excess results by grub_

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.