November 17, 2008

PERL: Snippet which traverses from root folder to sub folder inside it

"#!/usr/bin/perl
use strict;

&smash("/archive");

sub smash {
my $dir = shift;
opendir DIR,
$dir or return;
my @contents = map "$dir/$_", sort grep !/^\.\.?$/, readdir DIR;
closedir DIR;
foreach (@contents) {
next unless !-l && -d;
&smash($_);
}
}" forums.devshed.com

No comments:

Post a Comment