Thousands of Perth trees were destroyed by a beetle that could now spread across Australia, threatening forests and crops.