Melville lost plenty of wickets early to be at 8-49, before Tom Scollay (52) managed a match-winning half-century to lead the side to 91 all out.
Jacob Van Galen was terrific with the ball, taking 4-28, while fellow quick Liam Guthrie secured three wickets for the away team.
At 3-32, Perth looked likely winners before another batting collapse had the side lose 7-31 to be bowled out for 63.
Get in front of tomorrow's news for FREE
Journalism for the curious Australian across politics, business, culture and opinion.
READ NOWDrew Porter was outstanding with a five-wicket haul, while Tom Kerr-Sheppard produced four wickets.
Melville finished the day at 2-44, with Porter completing his performance at 17 n.o.
MORE: Danny Green slams Ellenbrook pub fight
MORE: $100 million performing arts centre touted for Joondalup
MORE: Photos of bird of prey giving Trigg locals a fishing lesson