Tourists from North America, Australia, Japan, Malaysia, Singapore and the European Union (and many others, check with the nearest Peruvian embassy or foreign ministry for the latest information, albeit in Spanish) will be issued a visa on arrival for up to 180 days.
When you enter the country, you must go through the immigration office (inmigración). There you will get a stamp in your passport indicating the number of days you are allowed to stay (usually 180 days). You cannot get further extensions, so make sure you apply for the time you think you need. If the 180 days are up and you want to stay longer, you can either cross the border to a neighbouring country (Ecuador, Colombia, Brazil, Bolivia or Chile) and come back the next day to get another 180 days, or stay too long and pay the penalty when you leave. The penalty for overstaying is only one dollar per day, which means that if you stay 30 days longer, it will cost you 30 dollars. Many people do this because it is much cheaper than leaving the country and coming back.
You will receive an additional official paper, which you should keep in your passport (be careful not to lose it!). When you leave the country, you must go to the emigration office (migración) where you will receive the exit stamp. Inmigración and migración are available at all border posts. Travelling to and from neighbouring countries by land is not a problem.