I've now got the variable declared as my $prefix = ''; Which should fix it? Or should I maybe make another variable to store the value that is going to be returned such as:
my $return;
$return = $prefix if $prefix;
$return .= join ' ', @data;
return $return;