Hi Monks,

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.pl
use Device; use System; my ( $serverAddress, $port, $reportFile ) = @_; my $System = new System($serverAddress, $port); my $dut = new Device('DEV',127.0.0.1,5000);
Device.pm
package 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); }
System.pm
package 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; }
Could someone please help..I have no clue how to move forward..Please let me know if the question is unclear.. Thanks a lot, Perllace

In reply to Strange Compilation Failed in Require Error by Perllace

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.