File::Temp can be used to set up randomly generated path and filenames, and you can even request that they not be deleted on exit. But there has to be more to your question than that. Surely you aren't looking to write purely random directories and files into your filesystem. There must be a pattern you intend to follow. For example, git stores blobs by their SHA1 hash, where a file's content, length, and name are hashed to come up with a SHA id. The first two digits of that ID become a directory name, and the remainder of the digits of the SHA become the filename of the blob within that directory. That way there's a repeatable means of generating seemingly random filenames that are unlikely to collide, and put them in directories that are relatively evenly distributed.

Your question, as it stands, really fails to communicate your specific needs. However, there are times where a purely pseudo-random filename placed in a purely pseudo-random directory is useful, and for those times, File::Temp is the common solution.


Dave


In reply to Re: how create random directories and files hierarchy by davido
in thread how create random directories and files hierarchy by gabrielsousa

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.