I would prefer if you had spent as much time refining the specification within the question you're asking as we're likely to expend answering your question. As it is written, your question is vague enough as to garner multiple interpretations. Possibly one of us will get lucky, answering the question you intended to ask. But in the process, several of us will answer questions we thought you asked, which may completely miss the vague intent of the question.

My guess is that you have, as you said, a file that contains a directory tree... which I will assume means a list of paths. Each path must include a file name, since you said "full path to each end-file." So what you might have is this:

/foo/bar/baz.txt /foo/bingo/cantaloupe/commotion.json /bar/diamonds.dconf ...and so on...

Where these actual files come from, I don't understand, but I am going to go with the guess that you need to create paths, and possibly populate them with files that you might be copying from somewhere.

For full path creation, without the need to build paths piece by piece, look at File::Path, which has a make_path function. This function can create a full path all in one shot.

For copying files into those paths, there's File::Copy. Both File::Copy and File::Path are core Perl modules, so you have no good reason (outside of "for educational purposes") to not use them.

There is a non-core module which may also be helpful if you're willing to pull modules from CPAN (which you should be willing and able to do): File::Copy::Recursive.

Turning one or more of these modules into a full solution is left as an exercise for the reader, who must know a lot more about his question than we do. ;)


Dave


In reply to Re: recursive function by davido
in thread recursive function by rikhardo

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.