good chemistry is complicated,
and a little bit messy -LW
Really Odd Bug With LWP and Device::SerialPortby kschwab (Priest)
|on Aug 08, 2013 at 16:16 UTC||Need Help??|
kschwab has asked for the
wisdom of the Perl Monks concerning the following question:
I've found an odd bug / interaction between LWP and Device::SerialPort and/or Win32::SerialPort. I've also found a workaround, so the reason for the question is pure curiousity...and perhaps notifying the module owner of the issue if I can figure out what it is.
The issue, in short, is this:
If I take a scalar variable that was created using LWP::UserAgent's $req->decoded_content method, and pass it to Device::SerialPort as something to be written, I get:
Here's the really odd part.
If I "disassociate" the variable that came from LWP before passing it to Win32::SerialPort or Device::SerialPort, everything works great. No warnings, no corrupted data:
Even more odd, other ways of "disassociating" the variable don't fix the problem.
Aside from $data=substr($data,0), the only other method that fixed the problem was writing the data to a file, and reading it back into a fresh new variable to pass to Device::SerialPort (and/or Win32::SerialPort).
I did double-check myself by doing a hex dump of the contents in $data...nothing odd. Just a short text string like "THIS IS A TEST".
Any ideas on what this might be, and why $data=substr($data,0) would fix it when other methods don't?