Per the documentation, preprocess receives a list (of entries in the current directory), and is expected to return a list (of entries). The purpose for this functionality is to provide you the ability to prune, filter, reorganize etc the list of entries as you sweep over them before the wanted function is called (it receives the list returned from preprocess).
The most basic test you can do is just immediately return the list the begin function receives:
sub begin {
my @entries = @_;
print "begin\n";
return @entries;
}
The reason you're getting "1", is because that's what a successful print statement returns, and in Perl, if you don't have an explicit return(), the result of the last expression evaluated is returned (in your case, the result of the print, meaning "1").
my $x = print "hi\n";
print "$x\n";
__END__
hi
1
|