allensim81
Technical User
Hi, i am new in perl.
I am trying to write a simple script to show an index.html.
however it works only 40%! only one item is shown in the index.html... can u please guide me step-by step? thanks in advance!
I am trying to write a simple script to show an index.html.
however it works only 40%! only one item is shown in the index.html... can u please guide me step-by step? thanks in advance!
Code:
#!/usr/bin/perl
$httrackpath = "/usr/local/bin";
$websites="/data/websites";
opendir(DIR, $websites);
@files=readdir(DIR);
closedir(DIR);
for $file(@files) {
## List all files and directories from /data/websites ##
next if ($file =~ /^\./); # Ignore anything start with dot "."
next if (!-d "$websites/$file"); # Ignore if it is not a directory
next if ($file =~ /hts-cache/); # Ignore if it is hts-cache dir
print "[$file]\n";
open(HTML, ">/root/index.html");
print HTML "<html>\n<head>\n<title>$base$i</title>\n</head>\n<body>\n";
print HTML "<a href=\"$base$next.html\"><img src=\"$base$i.jpg\"></a>\n";
print HTML "</body>\n</html>\n";
print HTML "<· <A HREF=\"$file/index.html\">$file</A>";
close(HTML);
## proceed with the next function ##
## End, next website ##
}