I've never used Expect.pm before and it's not clear from your description, but I think this may be more complex than it appears.
I suppose that from the snippet you've posted that it is invoked on a 'nix system. If so, I guess that you're running it via a PC terminal session of some sort (telnet or Putty/other SSH type connection). If so, the program will expect keyboard codes that are agreed upon by both the 'nix system and the PC emulation software. The 'nix terminal type is probably the same as that defined for the account you're running it from. You'll need to lookup and use the escape sequences for that emulation and send them to Expect (hint: if you specify simple emulations, your control sequences can be simplified as well). You can try the methods explained by the other monks here, use the suggestions in Expect.pod:
Q: How do I send control characters to a process?
A: You can send any characters to a process with the print command.
To represent a control character in Perl, use \c followed by the lette
+r.
For example, control-G can be represented with "\cG" . Note that this
will not work if you single-quote your string. So, to send control-C
to a process in $exp, do:
print $exp "\cC";
Or, if you prefer:
$exp->send("\cC");
or build strings using the chr(
dec) function:
$vt220_pgup = chr(27) . chr(91) . chr(51) . chr(126);
print $exp $vt220_pgup
I could be totally off base on this, so please let me know if this is the case. I've made a lot of suppositions here but perhaps, if nothing else, it may give you a place to start.
--Jim