I am not sure if it will do this or not (I haven't personally used it) but you may want to look at Win32::SerialPort which has Win32API::CommPort. I suppose you could also open a pipe or something to COM2 (which you can use as a filehandle just like STDOUT or STDERR) to see what it returned.
Cheers,
KM