in reply to Re^4: Automatic User input
in thread Automatic User input

It's been a long time, and I no longer have Expect on hand, but I think you want to change this:
my $openprogram = system("progam.exe");
To:
my $openprogram = 'progam.exe'; # or '/path/to/program.exe'
Expect->spawn is analogous to system; you don't need both.