#!/usr/bin/perl use CGI; use CGI::Carp qw(fatalsToBrowser); use strict; use warnings; my $link_cgi='/cgi-bin/link.cgi'; my $name=$ENV{'REMOTE_USER'}; my $dir="/Library/WebServer/Documents/$name"; # neue CGI Instanz erzeugen my $cgi=CGI->new(); # Verzeichnis auslesen opendir (my $dh, $dir) or die "ERROR OPENDIR: $!"; # hole alle Verzeichnisse (-d) die "ome" (/ome/) im namen haben und sortiere (sort) sie. my @folders = sort grep {/ome/ && -d "$dir/$_"} readdir($dh); closedir($dh); # kein Ordner gefunden if(!@folders) { print $cgi->header(), $cgi->start_html('no data'), $cgi->h1('keine Daten vorhanden!'), $cgi->hr; $cgi->end_html; } # nur ein ordner gefunnden elsif(@folders==1) { # url zusammensetzen: my $uri="$link_cgi?ordnermenu=$folders[0]"; print $cgi->redirect( -uri=>$uri, -nph=>1, -status=>302 ); } else { print $cgi->header(), $cgi->start_html('Test'), $cgi->h1('test'), $cgi->start_form( -name => 'main_form', -method => 'POST', -enctype => &CGI::URL_ENCODED, -action => $link_cgi, ), $cgi->p( "Ordner auswaehlen :" ), $cgi->p( $cgi->popup_menu('ordnermenu', [@folders]) ), $cgi->p( $cgi->submit() ), $cgi->end_form, $cgi->hr; if (my @ordner=$cgi->param('ordnermenu')) { print $cgi->em(join(", ",@ordner)), $cgi->hr; } print $cgi->end_html; }