Help for this page

Select Code to Download


  1. or download this
    opendir DIR,$dir or die "Can't open directory.\n";
    @dir = readdir DIR;
    ...
        else {print $_," is not a file or a directory!\n";}
        
    }
    
  2. or download this
    foreach(@dir) {
        my $path = "$dir/$_";  # prepend dir
    ...
        elsif (-f $path) {print $path," is a file.\n";}
        else {print $path," is not a file or a directory!\n";}
    }