Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use strict;
- use warnings;
- use Path::Class;
- my $dir = dir('foo','bar'); # foo/bar
- # Iterate over the content of foo/bar
- while (my $file = $dir->next) {
- # See if it is a directory and skip
- next if $file->is_dir();
- # Print out the file name and path
- print $file->stringify . "n";
- }
- use Path::Class;
- `dir and file`. So now we know anytime we see the function dir,
- we are invoking the one from `Path::Class`.
- From the docs:
- dir
- A synonym for Path::Class::Dir->new.
- So the correct place to find docs on the object returned by dir is Path::Class::Dir
- # Iterate over the content of foo/bar
- while (my $file = $dir->next) {
- $dir_or_file = $dir->next()
- next if $file->is_dir();
Add Comment
Please, Sign In to add comment