Saturday, 25 April 2009

Recursive Directory Listing in Perl

#!/usr/bin/perl -w
use strict;
sub recurse($)
{
my($path) = @_;
$path .= '/' if($path !~ /\/$/);
print $path,"\n";
for my $eachFile (glob($path.'*'))
{
## if the file is a directory
if( -d $eachFile) {
## pass the directory to the routine ( recursion )
recurse($eachFile);
}
else
{
## print the file ... tabbed for readability
open (MYFILE, '>>data.csv');
print MYFILE "\t",$eachFile,"\n";
}
}
close (MYFILE);
}
## initial call ... $ARGV[0] is the first command line argument

recurse($ARGV[0]);

No comments:

Efficient and Reliable UI automation without Selenium

I have been experiencing satisfaction over UI automation efforts after a half-decade of my work in automation. The reason is new age tools ...