package @SQLData ... sub css { if needed, define css here, else link to it. this will be mostly used for html emails, given that linking to it will be a pain if it goes outside the company } sub foo { my $bar = shift(@_); my @output; my $sql = ("sql code here") my @array $sql->execute; while (@array = $sql->fetchrow_array) { if ($bar=='csv') { push(@output,"$foo[0],$foo[1]"} } else { push(@output,"$foo[0]$foo[1]"); } } $sql->finish(); return @output; }