|
-
Feb 21st, 2003, 05:36 AM
#1
Thread Starter
Addicted Member
Searching directory (Perl)
Hiyas,
How do I search a directory (let's call it '/asdf' to set things straight ) for all ".txt" files using CGI/Perl? The directory is a subdirectory of the directory where the CGI/Perl script is located. I want the results (the results being the filenames of all ".txt" files in the '/asdf' directory) stored in an array. I can't figure this out... Can anyone help?
Thanks in advance,
-Git
Last edited by git; Feb 21st, 2003 at 05:41 AM.
-
Feb 21st, 2003, 11:37 AM
#2
Member
Code:
chdir 'asdf' or die $!;
my @file_names = glob '*.txt';
-
Feb 22nd, 2003, 03:45 AM
#3
Thread Starter
Addicted Member
Cool - thanks for that!
BTW, one more (and hopefully final) question about Perl... How do I delete the entire contents of an array, aka remove all the array's elements?
Thanks again,
-Git
-
Feb 22nd, 2003, 10:49 AM
#4
Member
There are many different ways, the simplest being to just assign an empty list. But these all do the same thing.
Code:
@a = ();
$#a = -1;
undef @a;
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|