I have traveled to many cities all over the world with no problem. It just takes common sense. Anything that could happen to me in Peru could also happen to me in California. We have shootings, robberies, muggings, and murders here.
Just be sensible and you'll be fine.
Most Latin American cities designate a part of the city and beef up security, etc for the tourists. I went to Lima last year, and that part of the city is called Miraflores. Lots of fairly inexpensive places to stay, nice restaurants, shopping etc. You can definitely tell when you have left Miraflores for another part of the city. Enjoy your trip, Both Lima and peru are great !
Lima is horrible, polluted and full of thieves, I got robbed by a taxi in 2009.
Very safe If you have common sense, don't be fooled by the media, just don't go around flashing your wallet and foreign currency, oh and don't look around making concerned faces, just act normal as you would do at home and you'll be just fine. :)