Re: Listing en html

Pàgina inicial

Reply to this message
Autor: Edgar Bonet
Data:  
A: guilde
Assumpte: Re: Listing en html
Le vendredi 7 septembre, Christian Marillat a écrit :
> Ce qui m'intéresse c'est de partir d'un code pour que je puisse le
> modifier.


Cadeau. ;-)

#!/usr/bin/perl

# Quick and dirty script for generating an index.html file listing the
# contents of the current directory. Useful if
#     echo "Options Indexes" > .htaccess
# does not work for you (if the server is configured not to
# "AllowOverride Options" for your directory).


# Make sure there is no index.html already
die "index.html already exists.\n" if open INDEX, "index.html";

# List the directory
open LS, "ls|" or die "Could not ls\n";

# And print it in HTML
open INDEX, ">index.html" or die "Could not open index.html\n";
print INDEX
    "<html><head><title>Directory listing</title></head><body>\n";
while ($file = <LS>) {
    chomp $file;
    print INDEX "<a href=\"$file\">$file</a><br>\n";
}
print INDEX "</body></html>\n";
close INDEX;