perl instead of sed to work on osx and linux