Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
Keep It Simple, Stupid

How do I create, move and delete files and folders?

( #6192=categorized question: print w/ replies, xml ) Need Help??
Contributed by Anonymous Monk on Mar 27, 2000 at 00:50 UTC
Q&A  > files


I would like to be able to make it so that a code can make a folder with a variable name and put certain files in it.

Answer: How do I create, move and delete files and folders?
contributed by setantae

You'll want to read up on mkdir, open, rename and unlink.

Here's some example code. -- Ed.

mkdir 'MyDir', 0777 or die "Oops, couldn't make dir: $!"; open FILE1, '>MyDir/test1.file' or die "Couldn't open file: $!"; print FILE1 'This goes in test1.file'; close FILE1; chdir 'MyDir'; rename 'test1.file', 'MyName.txt'; unlink 'MyName.txt';


  • Please read these before you post! —
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others avoiding work at the Monastery: (8)
    As of 2014-03-14 09:19 GMT
    Find Nodes?
      Voting Booth?

      Have you used a cryptocurrency?

      Results (302 votes), past polls