>269>270です
>321さん、ありがとうございます
皆様のおかげで、一応動作するようになりました

#!/usr/bin/perl
use Expect;
$exefile = "gdb ./a.exe";
$command=Expect->spawn($exefile);
#$command->log_stdout(0);
$command->expect(5,'(gdb) ');
print $command "b main\n";
$command->expect(5,'(gdb) ');
print $command "r\n";
$command->expect(5,'(gdb) ');
print $command "q\n";
$command->expect(5,'The program is running. Exit anyway? (y or n)');
print $command "y\n";

それでは失礼します