Thread HTML Seite mit Links mittels Perl-Module erstellen (53 answers)
Opened by rooky at 2007-10-25 01:56

rooky
 2007-10-28 00:46
#101489 #101489
User since
2007-10-25
38 Artikel
BenutzerIn
[default_avatar]
Hallo könnte jemand das Sript bei scih testen damit wüsste ich ob bei mir bei apache das Problem liegt oder am Sript.
Das Skript
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/perl

use strict;
use warnings;
use HTML::Template::Compiled; # musst du wahrscheinlich noch installieren
use File::Find;
use CGI;
my @files;
find( \&wanted, '/home/user' );
my $cgih = new CGI;
print $cgih->header();

my $content = do{ local $/; <DATA> };
my $tmpl = HTML::Template::Compiled->new( scalarref => \$content );
my @links = map{ {HREF => $_, TITLE => $_ } }@files;
$tmpl->param( LINKS => \@links );
print $tmpl->output;

sub wanted{
push @files, $_ if /\.pdf$/;
}


__DATA__
<html>
<body>
<ul>
<%LOOP LINKS %><li><a href="<%= HREF ESCAPE=URL %>"><%= TITLE ESCAPE=HTML %></a></li>
<%/LOOP %>
</ul>
</body>
</html>

ruft dieses zweite auf

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#! /usr/bin/perl -w
eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
if 0; #$running_under_some_shell

use strict;
use File::Find ();

# Set the variable $File::Find::dont_use_nlink if you're using AFS,
# since AFS cheats.

# for the convenience of &wanted calls, including -eval statements:
use vars qw/*name *dir *prune/;
*name = *File::Find::name;
*dir = *File::Find::dir;
*prune = *File::Find::prune;

sub wanted;



# Traverse desired filesystems

Danke
File::Find::find({wanted => \&wanted}, '/home/user');
exit;


sub wanted {
/^.*\.pdf\z/s &&
print("$name\n");
}

sollte idearlerweise unter linux ausprobiert werden.

View full thread HTML Seite mit Links mittels Perl-Module erstellen