in reply to Re^3: Building SQL Query on the fly
in thread Building SQL Query on the fly

my $col_string = ''; for my $var ( sort {$$href{$a} <=> $$href{$b}} keys %$href ) { $col_string .= "$var,"; } chop $col_string; # remove final comma

I always view the chopping of a trailing comma in building an SQL statement as something of a Red Flag. It usually means that a join (in the Perl sense) is called for. For instance, the above snippet is better written as

my $col_string = join( ',', sort {$href->{$a} <=> $href->{$b}} keys %$href );

• another intruder with the mooring in the heart of the Perl