in reply to *.txt

Method 1:
foreach my $filename (<*.seq>) { print "$filename\n"; }

Update: (as per Abigail-II's comments below)

while (my $filename = <*.seq>) { print "$filename\n"; }

Method 2:

use IO::Dir; my $dh = IO::Dir->new('.'); while (defined(my $filename = $dh->read)) { next unless $filename =~ /\.seq$/; print "$filename\n"; }

And, there's at least 3-4 others people could come up with, depending on your exact needs.

------
We are the carpenters and bricklayers of the Information Age.

The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

Replies are listed 'Best First'.
Re: *.txt
by Abigail-II (Bishop) on Sep 29, 2003 at 16:17 UTC
    A while loop instead of a foreach is preferred in method 1. The foreach will store all matching files in a list, which could take lots of memory if there are many files. The while method doesn't store an intermediate list. (List vs scalar context behaviour of <>).

    Abigail