Fiscal depute Gillian Sim told a trial she found the sharp metal item in her tuna and cheese salad baguette during her lunch break.
She said she and her fellow Crown lawyer Paul Miele had picked up their lunch at a Dundee Subway store and taken it back to the fiscal's office to eat.
"We went back to the office and went into the kitchen area to sit and eat it there," she told a trial at Perth Sheriff Court.
"I had the first bite and it was fine and then had another couple and bit down on something hard. I kept whatever it was between my teeth.
"I pulled out what was in my mouth and found out it was a Stanley knife blade. I put the sandwich down and pulled it out of my mouth. Paul asked what was up and I showed him and then I said, 'what do I do with it?' I thought with it being a blade I better put it in something. I put it in a pot."
Miss Sim said she then told police officers working in the court about what had happened and was advised to report the find to environmental health.
She said she accepted some people might not like lawyers, and particularly prosecutors, but denied the blade could have been placed in the roll by a disgruntled criminal. She told the court it could have been placed there as the roll was being made, but said it did not leave her sight before she started eating it.
Mr Miele said: "We went back to the fiscal's office. At the time there was only me and Gillian there and we sat down to have lunch.
"I remember Gillian was eating hers when she said 'yeuch' or something like that. I remember laughing and saying 'is it a hair?' Then she took some food from her mouth and also a blade which had been in the sandwich. Obviously, I was very surprised."
Under the auspices of Edinburgh-based SS North Ltd, the company is being prosecuted for providing a roll with a craft blade in it at the Dundee branch of Subway on August 16, 2011.
It is alleged to have sold "a filled submarine roll to the purchaser's prejudice, which was not of the nature, quality or substance demanded by the purchaser, in that the roll had a craft blade or similar instrument within its contents".
The allegedly offending submarine roll, which contained tuna, cheese, mayonnaise, cucumber and gherkins, was sold from the company's store in the Overgate Shopping Centre.
The trial continues.
l According to the firm's website: "The Subway system is committed to providing a wide range of great tasting, healthier food choices while reducing our environmental footprint and creating a positive influence in the communities we serve around the world.
"From streamlining our supply chain and using sustainable sourcing practices, to ensuring our high food quality and food safety standards are met, we not only help reduce energy, water usage and waste but we're taking care of the environment too. Ultimately, the health of our population depends on the health of the planet."