Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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.


In reply to Re: How do I recursively process every file in a given directory? by Anonymous Monk
in thread How do I recursively process every file in a given directory? by vroom

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2024-04-20 03:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found