Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- opendir my($dh), $dirname or die "Couldn't open dir '$dirname': $!";
- my @files = readdir $dh;
- closedir $dh;
- #print files...
- $listing = `ls`;
- File::Find::Rule->maxdepth(1)->directory->in($base_dir);
- #!/usr/bin/perl
- use strict;
- use warnings;
- # See http://search.cpan.org/~rclamp/File-Find-Rule-0.32/README
- use File::Find::Rule;
- # If a base directory was not past to the script, assume current working director
- my $base_dir = shift // '.';
- my $find_rule = File::Find::Rule->new;
- # Do not descend past the first level
- $find_rule->maxdepth(1);
- # Only return directories
- $find_rule->directory;
- # Apply the rule and retrieve the subdirectories
- my @sub_dirs = $find_rule->in($base_dir);
- # Print out the name of each directory on its own line
- print join("n", @sub_dirs);
- chdir $dir or die "Cannot chroot to $dir: $!n";
- my @files = glob("*.txt");
- my @files = map { chomp; $_ } `find`;
- my $dir = </dir/path/*>
Add Comment
Please, Sign In to add comment