This works well:
my $PortObj;
$PortObj = new Win32::SerialPort ("COM12") || die "Can't open COM\n";
However, when I try to provide a variable instead of “COM12” from the TK entry, like this:
my $portNumVar = "12";
my $portNum = $mw->Entry(-justify=>'center',-width=>'5',-textvariable=>\$portNumVar)->pack();
Inside the subprogram (after pressing the button):
my $PortObj;
my $com = "COM".$portNumVar;
print $com;
$PortObj = new Win32::SerialPort ($com) || die "Can't open COM\n";
I get this error:
Win32 :: API :: Call: parameter 1 had a buffer overflow on C: /Perlx86_5.16/site/lib/Win32API/CommPort.pm line 176.
How is this possible? Shouldn't it be?
Thanks Mark.
source
share