in reply to gnuplot problems

And if you used join you wouldn't have to worry about incorrect trailing seperators.

$graph .= join( ", \\\n", map qq{"tmp/$random.dat" using 1:$_ title '$inputs[ $_ - 2 ] +' with lines}, 2..$#inputs+2 );

Update: And of course you'd append a "\n" on the end of that otherwise you're right back where you were stuck before. %/