in reply to regex to break on commas

sub something { #takes a hashref as an argument. creates a copy of the hash, scans e +ach of the values for any occurence of a comma and if necessary, adds + a space after it. #Returns a hashref to a newly constructed, thus corrected, hash. my $hashref = shift; unless(ref($hashref) eq 'HASH') { print "argument to \'something\' must be a hash reference"; retu +rn; } my %oldhash = %{$hashref}; my %newhash; foreach my $key (keys(%oldhash)) { my $value = $oldhash{$key}; $value =~ s/,/, /g; $newhash{$key} = $value; } return \%newhash; }
It isn't the prettiest or the most efficient, but it does the job and clearly shows how it does it.

Disclaimer: untested code, use at your own risk.

Update: untested indeed. that's what happens when engaging the black arts of regex without the proper sacrifice of a virgin first. the regex of the poster below me seems to work a little better ;-)

Remember rule one...