People 'perched themselves' on the railing [=people sat on the railing] to get a better view.
He stood there in his coat, a small hat 'perched' on/atop his head.
The castle 'is perched' high in/among the hills of Scotland.