Too many prisoners in Perth Prison have been living in "dreadful conditions" due to overcrowding, according to an official report.
Dr McLellan was concerned about overcrowding
The chief inspector of prisons said the sharing of cells and slopping-out had led to "very bad conditions" in one of the halls.
Despite good relations between staff and inmates Doctor Andrew McLellan found a lack of activity for inmates.
However, a prison service spokesman insisted problems were being addressed.
C Hall, which was of key concern to Dr McLellan, is due to be replaced.
The prisons inspector discovered that, since the last check, some improvements have been made in the prison, which houses about 700 inmates.
He said: "It would be possible to write a gloomy report on Perth Prison. This is not a gloomy report.
"Good relationships between staff and prisoners continue - this was agreed by
every group of prisoners and by staff, and was confirmed by what was seen and
heard during the inspection.
"The imminent building work at Perth Prison offers the prospect of a renewed prison by the end of the decade.
"The conclusion of the building work will create much better conditions and
facilities for prisoners. This is also a positive prospect for members of staff, since it offers good working conditions."
But Dr McLellan warned: "In the meantime every effort must be made to address the issue of slopping-out in C Hall and the problems associated with overcrowding."
A Scottish Prison Service (SPS) spokesman said: "The SPS and Scottish Executive are currently spending approximately £1.5m per week on the prison estate to replace unfit accommodation and end slopping-out."
C Hall at Perth Prison is one of Scotland's most notorious jail blocks.
An investigation was launched in June 2002 after a disturbance at the prison that month involving about 40 prisoners.
Inmates had refused to return to their cells in C Hall but the trouble was brought under control an hour later.
A full inspection of prisons in Scotland normally takes place every three years and examines all aspects of the jail.
However, Historic Scotland said the hall, which dates from the 19th century, is architecturally important and should be preserved.
It was part of the original Perth Prison built to house thousands of French prisoners from the Napoleonic War. It is recognised as one of the most outdated in Scotland.