my $rule = File::Find::Rule->file->name("*.jpeg")->maxdepth(1)->start( "/web" ); while ( defined ( my $image = $rule->match ) ) { ... }