use strict;
my $str = 'SELECT tbl_Generic_Tool.Generic_Type_ID, tbl_ref_Generic_Type.Generic_Type,
tbl_Hex.ODD_Micap,tbl_Hex.Hex_ID,tbl_Hex.Hex_No ,Min(tbl_ref_Phase.Phase) AS FirstOfPhase,tbl_ref_Building.Building_Abbrev,tbl_ref_Status_Equipment.Status_Equipment
GROUP BY
tbl_Generic_Tool.Generic_Type_ID,tbl_ref_Generic_Type.Generic_Type,tbl_Hex.ODD_Micap,tbl_Hex.Hex_ID,tbl_Hex.Hex_No,tbl_ref_Building.Building_Abbrev,tbl_Hex.Status_Equipment_ID,tbl_ref_Status_Equipment.Status_Equipment
HAVING
(((tbl_Hex.ODD_Micap) < CONVERT(DATE,GETDATE()))
AND ((tbl_Hex.Status_Equipment_ID) = 2)))¦ AS H
LEFT JOIN tbl_POC_Assigned ON H.Hex_ID = tbl_POC_Assigned.Hex_ID
GROUP BY
H.Generic_Type
,H.Building_Abbrev
,H.ODD_Micap
,H.Hex_ID
,H.Hex_No
,H.Status_Equipment';
my $regex = qr/(\S)(,)(\S)/mp;
my $subst = '\\1\\2 \\3';
my $result = $str =~ s/$regex/$subst/rg;
print "The result of the substitution is' $result\n";
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Perl, please visit: http://perldoc.perl.org/perlre.html