in reply to readline() on unopened filehandle

$pfaminput is just a scalar containing file path, not a filehandle. You need to open a filehandle in order to read from it.
Sorry if my advice was wrong.