You might try using the x3270 (or was it s3270?) program, which
is an open-source IBM 327x terminal emulator. It has a scripting
part that you can use in it, so you should be able to drive it
with a perl program.
I don't know where to get the original project, as I got it as
a package in cygwin. It worked well when I had a need to hit our
mainframe a couple of years back.