A married father had sex in a derelict building with an underage boy after meeting him on a website.
Douglas Sinclair sodomised the 14-year-old, who had claimed to be 18 online but revealed his true age when the pair met.
The offence came to light after the boy, who cannot be named for legal reasons, was involved in an incident at his school.
Depute fiscal Charmaine Gilmartin said the teenager admitted to a family member that he had used a chat site to engage in sexual acts with the accused and others.
Perth Sheriff Court heard the pair met in a disused building in the grounds of Murray Royal Hospital and had sex on an old curtain.
Police were able to recover the curtain and found DNA belonging to both the boy and to Sinclair.
The 32-year-old initially denied the offence when confronted by police.
However, in court on Tuesday, Sinclair, of Burnside Way, Blackford, admitted that on one occasion between August 2015 and January 2016 in the grounds of Murray Royal Hospital he had consensual sex with the under aged teenager and caused the boy to perform a sex act on him.
Sentence was deferred for reports and Sinclair was remanded in custody.