Swapped out sed inline replace for perl for portability

For background see http://stackoverflow.com/questions/5694228/sed-in-place-flag-that-works-both-on-mac-and-linux