#!/usr/bin/perl use strict; use warnings; use CGI ':all'; use CGI::Carp qw(fatalsToBrowser); ######################## our $PATH = "/home/foo/www/dir"; { my @files = sort grep /html$/, glob $PATH; print param() ? selection_report( @files ) : selection_list( @files ); exit; } sub selection_report { return header_template() . center( h3( 'Finished...' ) . "You selected: " . join(", ", param('files') ) ) . footer_template(); } sub header_template { return header() . start_html( -title => 'MY SIMPLE FILE SELECTOR', -bgcolor => '#ffffff', -text => '#000000', -link => '#000000', -vlink => '#000000', -alink => '#000000' ); } sub footer_template { return br() . a( { href => 'javascript:history.back()' }, 'Go Back...' ) . small( small( '...' ) ) . end_html(); } sub selection_list { my @files = @_; return header_template() . center( h2( 'MY SIMPLE FILE SELECTOR' ) . br() . br() . small( b( "The following [$#files] files were found in the [$PATH] directory." ) ) ) . br() . br() . table( div( { -align => 'center' }, center( table( { -width => 246 }, Tr( td( { -align => 'left', -width => 312 }, start_form( -method => 'POST' ) . li( { -type => 'square' }, font( { -size => 2 }, i( 'Select files' ) ) . br() . map( b( checkbox_group( 'files', $_ ) ), @files) ) . p( submit( -name => 'create_list', -value => 'Create' ) ) . end_form() ) # ) # ) # ) # ) # ) # . footer_template(); }