I think you're going to need to define "talking together" a little better, both for your benefit and ours. If you mean "sending external signals to a running Flash process", then you're probably better off looking into ActionScript to communicate directly with your machine, rather than processing keystrokes etc. though Perl.
Cheers, Ben.