http://www.perlmonks.org?node_id=6192

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

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.

Originally posted as a Categorized Question.

  • Comment on How do I create, move and delete files and folders?

Replies are listed 'Best First'.
Re: How do I create, move and delete files and folders?
by setantae (Scribe) on Mar 27, 2000 at 03:55 UTC
    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';