|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > Perl and Path |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|