Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: Something like File::Find with sorting

by moritz (Cardinal)
on Feb 16, 2013 at 17:40 UTC ( #1019051=note: print w/replies, xml ) Need Help??

in reply to Something like File::Find with sorting

First assemble all the file names, then sort and print:

use strict; use 5.01; use File::Find; my $dir = "lib"; File::Find::find (\&search, $dir); my @files; sub search { push @files, $_ if -f; } say for sort { lc($a) cmp lc($b) } @files;

Replies are listed 'Best First'.
Re^2: Something like File::Find with sorting
by Anonymous Monk on Feb 16, 2013 at 18:47 UTC

    Or if you want a per-directory view,

    my @files; sub search { push @files, $_ if -f; } sub handle_directory { @files = sort { lc($a) cmp lc($b) } @files; # do something with @files print "@files\n"; # get ready for the next directory undef @files; } File::Find::find( { wanted => \&search, bydepth => 1, postprocess => \&handle_directory }, $directory );

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1019051]
[marto]: fortunately my bad jokes and puns don't fall into those categories :P
[Corion]: :-D
Corion discovers a new shiny toy to try out over the (longish) weekend. Since I've done some more with websockets, maybe I'll try writing a webserver that implements hot-reloading of HTML(+CSS, +Javascript) in the browser. Edit the local file and ...
[Corion]: ... the browser(s) get a ping to a) refresh the page or b) reload "just" the changed parts, keeping the scroll position etc.

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2018-04-26 10:41 GMT
Find Nodes?
    Voting Booth?