blob: 363f870661d18107c63ee840ea913a9ce80aef01 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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;
|