ok,

You're already building a hash of the directory structure you said, so along that vein how about this (untested piece of code)

use File::Find; # these should work on any platform : ) use File::Copy; # i'm naming your target directory hash %files, # and the directories are $target and $source (strings) sub checker { return if exists %files, $_; copy "$target$_", $File::Find::name; } find {wanted => \&checker}, $source;
This is the first code that pops to mind. It doesn't handle directories inside of directories well at all, but if you take a look at the File utilities you should be able to get a good feel for what it's lacking. Also, for testing if a file is the same as another, you could use File::stat which would be much more specific than just names of files. And finally, for creating the target hash structure to begin with you might want to use File::Find to help you traverse correctly down the tree. That way you don't get any infinite directories or some such nasty beasts.

find and copy do all of the grunt work here, you only need to modify the code to deal with how you laid out your hashes. It is untested, but it should work for directories that don't have any subdirectories in them.

Hope That Helps,
jynx


In reply to Re: Re: Re: Hash of directories? by jynx
in thread Hash of directories? by phathead22

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.