Hey!
I need a little help. How do get the name of every file in a directory? They're all text files. So, could I use something like "*.txt"?
Thanks!
--Edge
Hey!
I need a little help. How do get the name of every file in a directory? They're all text files. So, could I use something like "*.txt"?
Thanks!
--Edge
japhy posted this at 00:32 — 1st March 2001.
They have: 161 posts
Joined: Dec 1999
Since you're using Perl, you could use a very-Perl approach:
opendir DIR, $path or die "can't read $path: $!";@text = map "$path/$_", grep /\.txt$/, readdir DIR;
closedir DIR;
'
Or you could take the let-the-OS-do-it approach:
@text = glob "$path/*.txt";'
Jeff japhy Pinyan -- accomplished Perl teacher, author, and hacker
Are you a Monk?
Perl Guru Forums
Visit #perl on DALnet