SunQuest
           Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!
  #1  
Old March 10th, 2001, 01:00 AM
devCisk devCisk is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 29 devCisk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question

I'm a beginner to perl.. and i'm trying to write a script that just displays contents of a directory..

Basically i ask the user what directory to use and then output the full path of it out the browser. How can i do this? I don't want it to depend on where i put the perl script in..

I can open the directory just fine and loop through each file but i don't know how to get the full path of that file. Is it some type of ENV variable? Also.. i would like this to be able to display in a webpage. Like if i print out each full link.. i want me to be able to click the link and go to that file. Like if a file is in
htdocs/txt/txt1.txt htdocts shouldn't be in the url... is there a way to do this? I guess i'd have to take that off and put the http://www. address? any hints/ideas?

thanks in advance,
Cisk

Reply With Quote
  #2  
Old March 10th, 2001, 02:12 AM
dsb dsb is offline
PerlGuy
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2001
Posts: 714 dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Days 15 h 44 m 20 sec
Reputation Power: 36
Send a message via AIM to dsb
Not really sure what you want to do.
If you are trying to list the contents of the directory specified, you could use the opendir and readdir functions like so:
Code:
opendir( DIRHANDLE, "/path/nextpath" ) || die "Nope\n";

while ( $file = readdir(DIRHANDLE) ) {
    print $file, "\n";
}

If you are trying to display the full path of the specified directory, I'm not really sure how you could do that since there could be more than one directory with the same name on the system.
For example '/usr/lib' and '/usr/local/lib'

Hope that helps.
__________________
- dsb -
Perl Guy

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Perl and Path


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway