#!/usr/bin/perl -wT use strict; use CGI qw(:standard escapeHTML); use vars qw ( way too many of them); my $query = CGI->new(); @names = $query->param; ... (preparatory material including a heredoc for the top of the page to be returned) foreach $name (@names) { @values = $query->param( $name ); for $values(@values) { if ( $values[1] =~ /^0$/ ){ last; } # Note 1 &untaint($name, $values ); # ... Test and print html-table rows, if $values[1] != 0 } } } #### I0=nameofplant Q0=\d+ P0=\d+\.[\d]{2} IT0=\d+\.[\d]{2} I1=anotherplant Q1=\d+ P1=\d+\.[\d]{2} IT1=\d+\.[\d]{2} etc... #### my $query = CGI->new(); @names = $query->param; ... NAMES: for $name (@names) { $values = $query->param( $name ); if ( $flag == 0 ) { #set the first time thru for special purpose data &checkacct(); # which is formatted differently than the rest... next NAMES; } else { &untaint( $name, $values ); &tohtml( $name, $values ); } } #### if ( $name =~ /^I\d+$/ && $values =~ /[A-Za-z\s_\'\-\.]+/ ) { #I\d+ print "\n" . $name . "   " . $values . "<\/td>\n"; # start new row next; } elsif ( $values =~ /^[\d]+$/ && $name =~ /^Q\d+$/ ) { # Q0,Q1 print "Quant: " . $values . "\n"; next; # plus 4 more for P\d+ and IT\d+ cases and another pair of special cases #### "ID: " . $name . " $values "; #(where the inner loop is at [0]) " Quantity: " . $values[1];