Scripting >> Perl >> How to work with directories



1.   Opening directories
     $indir = "somedirname";
     opendir(indirhandle,$indir);
 
2.   Listing directories
     $indir = "somedirname";
     opendir(indirhandle,$indir);
     @files = grep{!/^\./} readdir(indirhandle); #remove dots by grep
     foreach $file (@files) { print "$file\n"; }

3.   Changing directories

     In windows, to change to c:\apache and in Unix, to change to /apache

     chdir("/apache");