in reply to Add spaces before capital letters

Use the s/// operator. Search for a capital letter: [A-Z], capture it, then replace with the capture and a space. Use the "begin of line" anchor with a negated look behind to make sure the capital isn't beginning the line. In other words:
s/(?<!^)([A-Z])/ $1/g