replaced sed with perl -p -e