in reply to Array output

I notice that you do not delete the temporary file at end, but do you need it? You can read the output from a program direct into an array (or scalar) with qx (or `back-ticks`):
@stuff = qx(pkginfo $pkg $PKG 2> /tmp/vperror);
This replaces the system and open commands, and the read. stderr is not affected, so you might want to unlink the file.