CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
newbie needs CGI help...

 



ImustDIE
Novice

Dec 4, 2000, 3:40 PM

Post #1 of 3 (219 views)
newbie needs CGI help... Can't Post

Im writing a simple page creation script, and it saves each user and a seperate .dat file and i want to list all files in a directory and remove .dat extensions, so it just shows their names... any tips?


sleuth
Enthusiast

Dec 5, 2000, 10:26 AM

Post #2 of 3 (219 views)
Re: newbie needs CGI help... [In reply to] Can't Post

 Sure, this will do it,

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


$dir = "/path/data/path";
opendir (DIR, $dir) or die "can't open $dir: $!";
@files =
sort
grep { -f "$dir/$_" }
readdir (DIR);
closedir (DIR);
foreach $line (@files)
{
$file = "$line";
$file =~ s!\.dat!!g;
$tmp="$line";
if ($tmp =~ m,\.(.+),){$ext="$1";}
if ($ext eq "dat"){
print "$file";
}
}
</pre><HR></BLOCKQUOTE>

Sleuth

[This message has been edited by sleuth (edited 12-05-2000).]


ImustDIE
Novice

Dec 6, 2000, 3:41 PM

Post #3 of 3 (219 views)
Re: newbie needs CGI help... [In reply to] Can't Post

thanks!

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives