A police officer is recovering in hospital after suffering a fractured skull when he was attacked with a samurai sword at a house in Perth's southern suburbs.

The senior constable — who is believed to be in his mid 50s — was attacked about 5:30pm on Wednesday at the house on Parkin Street in Rockingham after he was called to a domestic disturbance.

Police said the alleged attacker left the house before officers arrived, before returning to the scene and assaulting the senior constable with the sword.

The officer was left with a chipped skull and a deep wound to his head and was taken by ambulance to Royal Perth Hospital.

He lost about a litre of blood and needed 25 stitches but his injury was not life-threatening, police said.

A hospital spokesperson said he was in a stable condition.

Alleged attacker facing six charges

Police said the alleged attacker — a 45-year-old Beeliar man — had to be tasered before being restrained.

He has been charged with six offences including intent to maim by unlawful wounding, being armed in a way to cause fear and breaching a violence restraining order.

The man is due to appear in court in Rockingham.

Police said the sword had been seized as evidence.

Sergeant hit with rock in Pilbara

In a separate incident just hours later, a police officer was hit on the head with a rock while on duty in the Pilbara town of Newman.

The sergeant was attending a disturbance at a property when the rock was thrown.

He suffered a head wound and required stitches.

Police are searching for a 21-year-old man they want to question about the attack.