- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Create, Delete and Change Directories in Perl
You can use mkdir function in Perl to create a new directory. You will need to have the required permission to create a directory.
#!/usr/bin/perl $dir = "/tmp/perl"; # This creates perl directory in /tmp directory. mkdir( $dir ) or die "Couldn't create $dir directory, $!"; print "Directory created successfully\n";
Remove a directory
You can use rmdir function in Perl to remove a directory. You will need to have the required permission to remove a directory. Additionally this directory should be empty before you try to remove it.
#!/usr/bin/perl $dir = "/tmp/perl"; # This removes perl directory from /tmp directory. rmdir( $dir ) or die "Couldn't remove $dir directory, $!"; print "Directory removed successfully\n";
Change a Directory
You can use chdir function in Perl to change a directory and go to a new location. You will need to have the required permission to change a directory and go inside the new directory.
#!/usr/bin/perl $dir = "/home"; # This changes perl directory and moves you inside /home directory. chdir( $dir ) or die "Couldn't go inside $dir directory, $!"; print "Your new location is $dir\n";
- Copy, Rename and Delete Files in Perl
- Database DELETE Operation in Perl
- Create directories recursively in Java
- C# Program to create new directories
- How to create directories (hierarchically) in Java?
- Create References in Perl
- How to create Array in Perl?
- Directories in Python
- How to get all the directories and sub directories inside a path in C#?
- Listing out directories and files in Python?
- How to create Database Connection in Perl?
- Create a Report Header using Perl
- Listing out directories and files using C#
- Generate temporary files and directories using Python
- How to create Directories using the File utility methods in Java?