You can do that in three lines of perl or sed using a regular expressions (and one of those was just to add extra spaces after the commas). If this is the sort of thing you are doing then you should ensure your well familiar with them cos it makes manipulation like this so easy.

Code:
$in = '<path d="M 258.59905,189.69191 80.812204,365.45845 264.65997,692.74788 220.21325,510.92042 519.21841,434.14883 385.87827,246.26045 z" />';
$out = $in;

$out =~ s/<path d="M /LINESTRING (/;
$out =~ s/ z" \/>/)/;
$out =~ s/,/, /g;

print "Before: $in\n";
print "After : $out\n";



# Results:
#
# Before: <path d="M 258.59905,189.69191 80.812204,365.45845 264.65997,692.74788 220.21325,510.92042 519.21841,434.14883 385.87827,246.26045 z" />
# After : LINESTRING (258.59905, 189.69191 80.812204, 365.45845 264.65997, 692.74788 220.21325, 510.92042 519.21841, 434.14883 385.87827, 246.26045)
#