LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 04-28-2003, 08:08 AM   #1
ocularbob
Member
 
Registered: Nov 2002
Location: brooklyn NYC
Distribution: gentoo
Posts: 212

Rep: Reputation: 30
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)

Last edited by ocularbob; 04-28-2003 at 08:10 AM.
 
Old 04-28-2003, 09:12 AM   #2
ocularbob
Member
 
Registered: Nov 2002
Location: brooklyn NYC
Distribution: gentoo
Posts: 212

Original Poster
Rep: Reputation: 30
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
 
Old 04-28-2003, 09:33 AM   #3
LoungeLizard
Member
 
Registered: Apr 2003
Location: Tampa, Florida
Distribution: Slackware 10 and happy,Suse,Red Hat, Vector
Posts: 274

Rep: Reputation: 30
glad you got it working you saved me alot of typing...lol glad you got it working
 
Old 04-29-2003, 08:40 AM   #4
ocularbob
Member
 
Registered: Nov 2002
Location: brooklyn NYC
Distribution: gentoo
Posts: 212

Original Poster
Rep: Reputation: 30
yeah no kidding
thanks anyway
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl CGI:Can't locate CGI.pm supermyself Programming 13 09-10-2007 06:22 AM
cgi perl : I cant get perl to append my html file... the_y_man Programming 3 03-22-2004 05:07 AM
Apache2 CGI-Perl will not read files fefeh Linux - Software 0 06-30-2003 08:07 PM
cgi+perl barbanero General 0 04-07-2002 12:48 PM
Problem with perl and cgi files JSP Linux - General 1 03-22-2002 08:01 AM


All times are GMT -5. The time now is 12:32 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration