diff options
Diffstat (limited to 'test.pl')
-rwxr-xr-x | test.pl | 35 |
1 files changed, 35 insertions, 0 deletions
@@ -0,0 +1,35 @@ +#!/usr/bin/perl +use strict; +use warnings; + +use Path::Class; + +sub trans { + my ($dir, $cb) = @_; + + while(my $file = $dir->next) { + my $outfile = $file->stringify; + + # Some conditions + next if $outfile =~ /(\.|\.\.)$/; + next if $outfile eq $dir; + + if($file->is_dir()) { + # make a directory + trans($file, $cb); + next; + } + + $cb->($file); + } +} + +sub some { + my ($f) = @_; + + die "f is empty" if !$f; + + print "Inside some: $f\n"; +} + +trans dir("in"), \&some; |