#!/usr/bin/perl -w use strict; use CGI qw/:standard :html3/; use CGI::Carp qw( fatalsToBrowser ); print header, start_html('Order Ice Cream with Price'), h1('Order Ice Cream with Price'); generate_form(); print_results(); sub generate_form { print hr, start_form, strong('Your email: '), textfield( -name => 'user_email' ), br, br strong('Cone: '), radio_group( -name => 'cone', -multiple => 1, -values => [qw/sugar waffle/] ), br, br strong('Number of Units: '), textfield( -name => 'no_unit' ), br, br # Problematic Upload Entry strong('Choose File to upload: '), filefield(-name=>'upload',-size=>60),br, submit( -value => 'Submit' ), end_form, hr; } sub print_results { print "You ordered ", param('no_unit'), ' unit of ', param('cone'), ' cone.'; print br; my $ct = param('cone'); my $nu = param('no_unit'); my $uemail = param('user_email'); my $length; my $file = param('upload'); # This line print successfully print h2('File name'), $file; # But not the subsequent lines print h2('File MIME type'), uploadInfo($file)->{'Content-Type'}; while (<$file>) { print; $length += length($_); } print h2('File length'), $length; print br; }