From the last syllable of the Malay word apa, emphasised. It literally means "What [is that]?".
Not related to the word pergi (“to go”).
perghhh