note
LanceDeeply
This:
<code>
my $items_in_dir = @Dircontent;
if ($items_in_dir > 2) ..
</code>
won't work if some smart alec decides to create a subdir in your drop area. try using <code>-f</code>
<p>TISMTOWTDI:
<code>
use strict;
use warnings;
sub scandir
{
my $dir = shift;
my $fileProcessor = shift;
opendir (DIR, $dir) or die "Cannot open $dir: $!\n";
for (readdir DIR)
{
if ( -f )
{
&$fileProcessor($_);
}
}
close DIR;
}
sub do_something
{
my $filename = shift;
print "got file: $filename\n";
}
sub do_something_else
{
my $filename = shift;
print "got another file: $filename\n";
}
scandir('.',\&do_something);
scandir('.',\&do_something_else);
</code>
283849
283857