#!/usr/local/bin/perl use CGI qw/:standard/; use File::Basename; print header(); print_return_page_top(); print_results(); print_return_page_bottom(); ### subs ### sub print_results { my $file = param('upload'); my $time = time; unless ($file) { print h2("No file uploaded."); return; } ($base,$path,$type) = fileparse($file,'\..*'); my $uploaded_path = "\\path\\to\\uploaded_files\\"; $uploaded_path .= $base; $uploaded_path .= "_"; open FILE, ">$uploaded_path$time$type"; binmode FILE; while(read($file,$buffer,1024)) { print FILE $buffer; } print h2('Success!'), p("$file has been uploaded."); } sub print_return_page_top { print h1('Top of page') } sub print_return_page_bottom { print h3('Footer') }