daily pastebin goal
59%
SHARE
TWEET

Untitled

a guest Jan 21st, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4.  
  5. use Path::Class;
  6.  
  7. my $dir = dir('foo','bar'); # foo/bar
  8.  
  9. # Iterate over the content of foo/bar
  10. while (my $file = $dir->next) {
  11.  
  12.     # See if it is a directory and skip
  13.     next if $file->is_dir();
  14.  
  15.     # Print out the file name and path
  16.     print $file->stringify . "n";
  17. }
  18.    
  19. use Path::Class;
  20.    
  21. `dir and file`. So now we know anytime we see the function dir,
  22.     we are invoking the one from `Path::Class`.
  23. From the docs:
  24.     dir
  25.         A synonym for Path::Class::Dir->new.
  26.         So the correct place to find docs on the object returned by dir is Path::Class::Dir
  27.    
  28. # Iterate over the content of foo/bar
  29.  
  30.  
  31. while (my $file = $dir->next) {
  32.    
  33. $dir_or_file = $dir->next()
  34.    
  35. next if $file->is_dir();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top