Perrette said that the suspect grabbed her as she walked from her home on Cahuenga Terrace to a guest house she bought across the street.
"He grabbed me so forcefully, pinned my arm, punched me in the nose, forehead repeatedly telling me he was going to kill me," she tweeted.
Perrette said that he kept telling her his name was William.
"There was an empty garage behind me and I knew if he got me in there I knew I was dead. I knew I couldn't overcome him, I prayed my heart out [and] then finally said, 'William is a beautiful name, I have a little nephew named William.'"
Perrette said she shortly went into shock and collapsed on the sidewalk. The suspect fled the scene, and Perrette called police and several friends for assistance.
Her friend was able to track the homeless man down. He followed the suspect, later identified as 45-year-old David Merck, until police officers arrived and arrested him for investigation of aggravated battery.
Merck is being held in lieu of $100,000 bail.
Perrette said the experience has left her "shaken and traumatized."
"We need full mental health care," she tweeted. "We need housing and help for the homeless. We need to support our cops.
"I almost died tonight."
CORRECTION: We earlier reported the suspect's name was William Holton but Eyewitness News has since learned the suspect's name is David Merck. null