Thread datei upload anhand indexes
(1 answers)
Opened by Gast at 2008-02-06 17:22
Schnellschuß:
Code (perl): (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 33 34 35 36 37 #!/usr/bin/perl use strict; use warnings; use CGI qw( :standard ); use File::Spec::Functions; use Cwd; my $cgi = CGI->new(); my $index = $cgi->param('index'); my @files = find_files_by_index( $index ); print "index: $index\n@files", $/; sub find_files_by_index { my $idx = shift; my $dir = cwd(); my @files = (); opendir my $dh, $dir or die "$dir: $!\n"; while ( my $file = readdir $dh ) { my $fullpath = catfile( $dir, $file ); if ( !-d $fullpath and $file =~ m/_${idx}.[^.]+\z/ ) { push @files, $file; } } closedir $dh; return @files; } Getestet auf der Kommandozeile: Quote Fuer einen Test als CGI-Skript eines Webservers fehlen ein paar Sachen. meine Beiträge: I.d.R. alle Angaben ohne Gewähr und auf Linux abgestimmt!
Die Sprache heisst Perl, nicht PERL. - Bitte Crossposts als solche kenntlich machen! |