LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   CGI perl links to files in Dir (https://www.linuxquestions.org/questions/programming-9/cgi-perl-links-to-files-in-dir-57135/)

ocularbob 04-28-2003 08:08 AM

CGI perl links to files in Dir
 
I'm in the middle of writing my first perl script.(had to happen sometime)
So far when i click submit the script makes an HTML page that has the same look as the rest of the pages on my site.
and thats pretty swell. Now i need to read the contents of a DIR
and make a link to each file in that DIR. I've been trying to implement
readdir(), but not having much luck. I will gladly affero pay someone for helping me out with this as soon as I get paid for the job.
this is the relevant part of the script so far:

-------code-------
find( sub
{
return if($_ =~ /^\./);
return unless($_ =~ /\$filetype/i);
stat $File::Find::name;
return if -d;
return unless -r;

opendir(DIR, $scandir) or return;
readdir(DIR);
my $file_name = $1;
closedir(DIR);

print "<li><a href=\"$File::Find::name\">$file_name</a></li>\n";
},
'$scandir');
-----end---code-----

$filetype is defined by a popup in the form (and working properly)
$scandir is defined at the head of the script

thanks alot(and yes i do know that i'm a hack)

ocularbob 04-28-2003 09:12 AM

holy crap I got it to work!!!!!
 
So sorry for the false alarm but i figured it out!
Here is what worked just so this isn't a totally useless post

undef $/;

opendir(DNAME, "/blackhole/movies/featurefilms") || die "Unable to open the requested directory";

while( $filename = readdir(DNAME) ) {
print "<p>$filename<p>\n";
}

closedir(DNAME);

thanks anyway

LoungeLizard 04-28-2003 09:33 AM

glad you got it working you saved me alot of typing...lol glad you got it working

ocularbob 04-29-2003 08:40 AM

yeah no kidding
thanks anyway


All times are GMT -5. The time now is 09:22 AM.