in reply to Interpolating $1 within a variable
This method may not suit you, since it does not capture the initial string, but it evades the string evaluation technicalities:
This inserts a comma at the first word-nonword boundary in the string$ perl -le '$_=q(ab cdefg);s/(?<=\w)\b/,/;print;'
After Compline,
Zaxo
|
|---|