in reply to A TRUE-once variable

I know this doesn't fit the answer of finding a true once (the examples above me do this well), but maybe you should rethink the way you do your flow. Instead of adding a comma and a value every time the trueonce variable is false, why not push everything onto an array and join it for the final query.

my @values = (); while($whatever){ my $value = $got_from_somewhere; push @values, $value; } my $query = "INSERT INTO somewhere VALUES ("; $query .= join(" ,", @values); $query .= ")";

my @a=qw(random brilliant braindead); print $a[rand(@a)];