find( { wanted => \&get_files, preprocess => \&nodirs }, "$BASEDIR/$dir" ); sub nodirs { grep !-d, @_; } sub get_files { my @array; push @array, $File::Find::name if ( (/^(?!\.).*\.($INTYPES)$/i) || ( (/^(?!\.).*\.($INTYPES)\.($ENGZTYPES)$/i) && !(/\.($OUTTYPES)\.($ENGZTYPES)$/i) ) ); foreach (@array) { if ( ( exists( $globalfiles{$_} ) ) && ( ( $globalfiles{$_} ne 'submitted' ) || ( $globalfiles{$_} ne 'working' ) ) ) { next; } else { if ( -e $_ ) { my $lckfile = getlckfile($_); if ( -e $lckfile ) { next; } push @tmparray, $_; } } } }