Hi all, I need a little insight on the following code, as I learn the CGI module.
What's happening is, as the output to web page increases, with the number of entries, the order in which values are entered rearranges itself, when printing to the page. How can I assure printing the correct order? #!E:/www/perl/bin/perl.exe use strict; use warnings; use CGI qw( :standard ); use CGI::Carp qw( fatalsToBrowser ); my $gallonsUsed = param( "gallons" ); my $milesDriven = param( "miles" ); my $data = param( "hidden" ); $data .= "$gallonsUsed "; $data .= "$milesDriven "; print( header() ); print( start_html( -title => 'Miles Per Gallon' ) ); print <<Form; <form method="post" action="pg92ex3.10MilesPerGallon.pl"> <strong> Enter the gallons used: </strong> <input type="text" name="gallons"><br> <strong> Enter the miles driven: </strong> <input type="text" name="miles"><br> <input type="hidden" name="hidden" value="$data"> <input type="submit" value="Enter"> </form> Form my %values = split( ' ', $data ); my $i = 0; my $totGals = 0; my $totMilesDriven = 0; my $average = 0; my $totAverage = 0; foreach ( keys( %values ) ) { $i++; $totGals += $_; $totMilesDriven += $values{ $_ }; $average = ( $values{ $_ } / $_ ); $totAverage = $totMilesDriven / $totGals; print( p( "Trip: $i<br> Gallons used: $_<br> Miles driven: $values{ $_ }<br> The miles per gallon for this trip were: $average<br>" ) ); } print( p( "<strong>Total trips so far: $i<br> Total gallons so far: $totGals<br> Total miles so far: $totMilesDriven<br> Total average so far: $totAverage</strong>" ) ); print( end_html() ); Thanks, Ron Smith [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>