in reply to clearing spaces from data input

Try using this regex to strip out the spaces around commas before you do your parsing:

$blah =~ s/\s*(,)\s*/$1/g;