Hi ,
Below is my code, please let me know how can I send the $guiobject object so as it remanis unchanged when I access it from server.pm . As you can see the object printed by two print messages from CommSystem and Server.pm are different. Below is my code :
Below is my code, please let me know how can I send the $guiobject object so as it remanis unchanged when I access it from server.pm . As you can see the object printed by two print messages from CommSystem and Server.pm are different. Below is my code :
- ## start.pl
Code:
#!/usr/bin/perl
use strict;
use warnings;
use CommSystem;
CommSystem::init();
## CommSystem.pm
Code:
package CommSystem;
use strict;
use warnings;
use Tk;
use Exporter;
use GUI;
our @ISA = qw (Exporter);
our @EXPORT = qw ($guiobj);
our $guiobj;
my $mw = MainWindow->new();
$guiobj = GUI->new();
sub init
{
print "Sent object $guiobj \n";
system ("perl proc.pl");
}
1;
## GUI.pm
Code:
package GUI;
use strict;
use warnings;
sub new
{
my $class = shift;
my $self = {} ;
bless $self;
return $self;
}
1;
Code:
#!/usr/bin/perl use strict;
use warnings;
use Server;
my $server = Server->new();
$server->initServer();
## Server.pm
Code:
package Server;
use strict;
use warnings;
use CommSystem;
sub new
{
my $class = shift;
my $self = { object => $guiobj };
bless $self;
return $self;
}
sub initServer
{
my $self= shift;
print "passed object ", $self->{object}, "\n";
}
1;