Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use strict;
- use warnings;
- die "Usage: $0 <path to obj dir> <output index file>\n" unless scalar @ARGV == 2;
- my $path_to_obj = shift;
- my $path_to_out = shift;
- opendir(my $obj_dh, $path_to_obj) || die "Can't open $path_to_obj directory\n";
- die "Can't open file $path_to_out\n" unless open(OUT_INDEX, ">$path_to_out");
- my @files = readdir($obj_dh);
- foreach my $file_name (@files)
- {
- next if ($file_name eq "." || $file_name eq "..");
- my $file_path = $path_to_obj . "/" . $file_name;
- my $path_to_index = $file_path . "/index.htm";
- my $path_to_index_without_obj = "./" . $file_name . "/index.htm";
- next unless (-d $file_path);
- next unless open(INDEX_HTM, $path_to_index);
- while (my $line = <INDEX_HTM>)
- {
- if ($line =~ /<title>(.+)<\/title>/)
- {
- my $title = $1;
- print OUT_INDEX "<a href=\"$path_to_index_without_obj\">$title</a><br>\n";
- }
- }
- close(INDEX_HTM);
- }
- close($obj_dh);
- close(OUT_INDEX);
Advertisement
Add Comment
Please, Sign In to add comment