I've come up with this work snippet:

chdir( "C:\\files\\" ); 
local( @files ) = <*.plx>; 
foreach $file( @files ) { 
        if( !-d $file ) { 
                print "    <br><a href=\"$file\">$file</a> \n"; 
        } 
}

how would I add dir to this in addition to the files?

-----Original Message-----
From: "$Bill Luebkert"<[EMAIL PROTECTED]>
To: "Mark Bergeron"<[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Date: Sat Nov 23 17:10:28 PST 2002
Subject: Re: example / tutorial for listing files?

>Mark Bergeron wrote:
>> I being lazy here but, how would I look in a directory, create a list of all of the 
>files there and assign a link with the file name: <a href="filename.pl">filename</a> 
>and display it on say an index page for that directory?
>> 
>> Any help? Any sites I can get a quick and easy answer to this question? I want to 
>do something similar to using the FileSystemObject through ASP. And I know I'm asking 
>for it by saying that but, that's where I got the idea from.
>
>Less cross-posting please.
>
>There are several ways to do it.  I would use opendir/readdir to
>get the files and a regular expr. to eliminate the ones I don't
>want.
>
>opendir DIR, $dir or die ...;
>my @files = readdir DIR;       # slurp them into an array unless there are lots of 
>them
>closedir DIR;
>
>foreach (@files) {
>       next if /^\.{1,2}$/;    # drop . and ..
>       if (/\.html$/) {        # or whatever your criteria is
>                       # do your thing
>       }
>}
>
>Code something up and come back if you can't get it to work.
>
>-- 
>   ,-/-  __      _  _         $Bill Luebkert   ICQ=162126130
>  (_/   /  )    // //       DBE Collectibles   Mailto:[EMAIL PROTECTED]
>   / ) /--<  o // //      http://dbecoll.tripod.com/ (Free site for Perl)
>-/-' /___/_<_</_</_     Castle of Medieval Myth & Magic http://www.todbe.com/
>


___________________________________________________
GO.com Mail                                    
Get Your Free, Private E-mail at http://mail.go.com


_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to