Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Don't print on the last loop

by tphyahoo (Vicar)
on Jun 13, 2005 at 14:23 UTC ( [id://466176]=note: print w/replies, xml ) Need Help??


in reply to Don't print on the last loop

Maybe something along these lines? (Untested):
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++; }
Actually, the other solutions are a lot nicer, but... you know... timtowtdi... :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://466176]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2025-05-24 22:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.