in reply to How do I read files in a directory and not directories?

just that partial snippet looks ok .. two general ideas:

You can always put next unless -f $job; in the foreach -- that will exclude directories (see -X).

A File::Find::Rule approach:
my @files = File::Find::Rule->file() ->name(qr/^.{36}\.txt$/) ->maxdepth(1) ->in("G:/Perl_program/Input"); my @tags = map { /(.{36})\.txt$/ ? $1 : undef } @files;

Replies are listed 'Best First'.
Re^2: How do I read files in a directory and not directories?
by ikegami (Patriarch) on Mar 10, 2006 at 18:00 UTC

    my @tags = map { /(.{36})\.txt$/ ? $1 : undef } @files;
    should be
    my @tags = map { /(.{36})\.txt$/ ? $1 : () } @files;
    or else you'll end up with a bunch of undefs in @tags.

    >perl -le "print 0 + map undef, 1..2 2 >perl -le "print 0 + map { () } 1..2 0
      yeah, good point. i actually almost wrote it as my @tags = grep {defined $_} map { ... } @files; (though i like the ? $1 : () much better).. left it out because, in theory, it should never not match, and if it does fail to match, perhaps (no clue if he does or not) OP wants to trap those cases ...
      foreach my $tag (@tags){ die "found a blank" unless defined $tag; .... }
      (though i guess in that case you can't, very easily, tie the failing tag back to an offending file ... hm.)
        If you remove the undefs, you can still trap that case by using if (@files - @tags)