I also found something similar today
my $select = "";
my (@fields) = ("field1", "field2", "field3", "field4", "field5", "field6", "field7", "field8", "field9", "field10", "field11", "field12", "field13", "field14", "field15", "field16", "field17", "field18");
foreach my $f (@fields)
{
$select .= "$f,";
}
chop $select;
For those unfamiliar, @name= array variable, $name = scalar variable. 'chop' is interpreted as a function call with the intentional side effect of removing the last character from the scalar you pass it. As a bonus, plaintext strings surrounded by double quotes must be parsed by the interpreter (this is Perl) and variable names within them are replaced with values.