I've written a couple of perl wrapper modules for a C# Tool. The idea is that the script will pass a device name, port number and server address which is used to establish a communication socket. When I write a script to use these modules I get a Compilation Failed in require error
"Can't call method "_serveraddr" on an undefined value at Device.pm line 23. Compilation failed in require at Launch.pl line 11. BEGIN failed--compilation aborted at Launch.pl line 11."
Launch.plDevice.pmuse Device; use System; my ( $serverAddress, $port, $reportFile ) = @_; my $System = new System($serverAddress, $port); my $dut = new Device('DEV',127.0.0.1,5000);
System.pmpackage Device; use Command; use Comm; sub new { my $class = shift; my $self = { _device => shift, _serveraddr => shift, _port => shift }; bless $self, $class; return $self; } my $SockObj = Comm->new( $self->_serveraddr, $self->_port ); my $ComObj = Comm->new(); sub Action1 { my ( $self, $x, $y ) = @_; my $tmp = { 'hash1' => 'Command', 'value1' => $x, 'value2' => $y, 'Device' => $self->{_device} }; $InputRequest = $ComObj->CreateInputString($tmp); $SockObj->WriteInfo($InputRequest); my $Response = $SockObj->ReadData(); $ComObj->TapResponse($Response); }
Could someone please help..I have no clue how to move forward..Please let me know if the question is unclear.. Thanks a lot, Perllacepackage System; use Comm; use Command; my $SockObj = Comm->new(); my $ComObj = Command->new(); sub new { my $class = shift; my $self = { _serveraddr => shift, _port => shift }; bless $self, $class; return $self; }
In reply to Strange Compilation Failed in Require Error by Perllace
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |