Perl/File::Next

From Wsms

Jump to: navigation, search

parent Perl

File::Next

File::Next is a CPAN module that lets you iterate through a directory tree.

#!/usr/bin/env perl                                                                                                          
use warnings;
use strict;
use File::Next;
$|++;

# print names of all files in user's home directory                                                                          
my $files = File::Next::files($ENV{"HOME"});

while ( defined ( my $file = $files->() ) ) {
  print $file, "\n";
}

installation

Install from CPAN using:

root@mckinley:~# perl -MCPAN -e 'install File::Next'

In case you forgot, I show how to use CPAN at 20070301a#Installing_Perl_Modules_on_Linux.

If this is the first time you are using CPAN, you may have to install some additional programs such as lynx.

see also

http://search.cpan.org/~petdance/File-Next-1.00/Next.pm

Personal tools