The Ducks moved in front of idle Nashville into sixth place in the Western Conference race. They are a point in front of Nashville, three ahead of Chicago and six ahead of Dallas and Calgary, who are tied for ninth.
Anaheim has won 12 of its last 15 games to surge into a strong post-season position. Calgary, which appeared certain of a playoff spot when March began, has lost seven out of nine.
Perry boosted his goal total to 46, two in front of Tampa Bay's Steven Stamkos for the league lead.
After Jarome Iginla opened the scoring for Calgary 2:58 into the contest, Bobby Ryan, Perry and Lubomir Visnovsky produced consecutive goals for the Ducks.
Anaheim took a 3-1 lead into the final period before Mark Giordano brought the Flames within one.
It remained a 3-2 game until Perry scored into an empty net with 47 seconds left in regulation.
Ray Emery made 23 saves to get the win. Miikka Kiprusoff was charged with the loss after stopping 18 shots.