in reply to Don't print on the last loop
Actually, the other solutions are a lot nicer, but... you know... timtowtdi... :)my @fields = my ( $cat, $schem, $tn, $cn, $dt, $tyn, $cs, $bl, $dd, $n +pr, $nul) = $sth->fetchrow_array() my $num_fields = @fields; #0-indexed number of fields, ie 10 if there +are 11 fields. $field_index = 0; while ( $cat, $schem, $tn, $cn, $dt, $tyn, $cs, $bl, $dd, $npr, $nul ) + { print "\t$cn "; if (($tyn eq 'DATETIME') || ($tyn eq 'DOUBLE')) { print "$tyn"; } else { print "$tyn($cs)"; } print " not null" if ($nul == 0); # need to put a condition on adding the comma to not add the com +ma on the last loop. if ( $field_index < $num_fields) { print ",\n"; } $field_index++; }
|
|---|