Here is a nice example from the book Higher-Order Perl by Mark Jason Dominus

This example is for win32, but it is easily changable:

use strict; use warnings; use Time::HiRes qw(gettimeofday tv_interval); my $start_time = [gettimeofday]; my $inp_dir = 'c:\temp\Tmp_User'; my ( $startdir ) = @ARGV; $startdir = $inp_dir; ( defined $startdir ) || usage(); walk_path( \&is_req_file, $startdir ); my $elapsed = tv_interval($start_time); $elapsed = sprintf "%.04f", $elapsed; print "\n...Elapsed is $elapsed sec\n"; 1; sub is_req_file { my ($filn) = @_; print "$filn\n"; return 1; } sub walk_path { my ( $filefunc, $startdir ) = @_; my $dos_cmd = "dir $startdir /b /S /A:-D"; map { $filefunc->($_) } ( split /\n/, qx{$dos_cmd} ); return; }

The advantage is, that it runs really fast on windows.

The missing sub usage is left as an exercise.


In reply to Re^2: list of files in subdirectories by Anonymous Monk
in thread list of files in subdirectories by ariczi55

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.