in reply to How do I recursively process every file in a given directory?

hehe, its my coffee brake so i couldnt resist to bake and submit a homegrown.
it aint pretty and the disclaimer took more mork then the code, but hey , i had three more minutes when it wuz finsihed !
yippy! back to work, if ya like going on holidays you need to get a new job folks, computers are sweet.
i'd just wish atari still survived, or amiga, or .. ohwell, *sigh*, ... i hope this helps someone out there :)
if it does, please enjoy but above all:
be nice
.recurser.pl: #!/usr/bin/perl # automagical-develop-and-do-what-you-want # licenced by your monthly # abZurd.org or abZurd-affiliate visit ;) # http://abzurd.com/legal/licence/automagical # easily install by following next three steps # step 1: # make sure you are programming in perl # yes?, ok, place sub in code :] sub recurse { my $dir = shift; my $action = shift; print "this isn't a dir! ($dir)\n" unless (-d $dir); opendir(DIR,$dir); foreach(readdir(DIR)) { if ($_ =~ /^\..?.?$/) { next; } if (-d "$dir/$_") { &recurse("$dir/$_",$action); } else { &$action("$dir/$_"); } } } # onwarths with the fun part # step 2: # create a sub that does something with all those # digital hunks of data (all bought and paid are they?) sub doMeCauseItHurts { printf "%s\n",shift; # ohyeah,ls -R|dir/s functionality ;) } # step 3: # just call it on the dir and pass it a reference to your sub: &recurse($ENV{USERPROFILE},\&doMeCauseItHurts);

Originally posted as a Categorized Answer.