in reply to How to get File::Find to return a list?
It doesn't have to be a global. I like the closure solution:
use strict; use File::Find; print "starting a find \n"; print join("\n", myfind('.')) . "\n"; sub myfind { my $dir = shift; my $list = []; find({wanted=>sub{findcb($list)}}, $dir); return((wantarray)?(@$list):($list)); } sub findcb { my $listref = shift; push @$listref, $File::Find::name; }
This is a closure right?
|
|---|