Cardinals hold on for 5-4 win over Pirates