How can I use File::Find in Perl? -


I'm a bit suspicious ... file :: find documentation ... what is equivalent $ "* .txt" to find my_dir -maxdepth 2 -name? Personally, I like that because this does not require you to make a callback routine.

  Use strict; Use data: Dumper; File Usage :: Search :: Rules; My $ dir = shift; My $ level = shift% 2; My @ file = file :: find :: rule-> (-) - & gt; Name ("* .txt") - & gt; Maximum office ($ level) - & gt; In ($ dir); Print dumper (\ @files);  

Or alternatively create an IETATOR:

  My $ ffr_obj = file :: Find :: rule-> file () -> Name ("* .txt") - & gt; Max amount ($ level) - & gt; Start ($ dir); While (my $ file = $ ffr_obj- & gt; match ()) {print "$ file \ n"}  

Comments