
kieron
New User
Oct 6, 2013, 11:33 PM
Post #1 of 1
(2663 views)
|
need help on object serialization and writing to pipe
|
Can't Post
|
|
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 : #start.pl
#!/usr/bin/perl use strict; use warnings; use CommSystem; CommSystem::init(); ## CommSystem.pm
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(); MainLoop; sub init { print "Sent object $guiobj \n"; system ("perl proc.pl"); } 1; # GUI.pm
package GUI; use strict; use warnings; sub new { my $class = shift; my $self = {} ; bless $self; return $self; } 1; ## proc.pl
#!/usr/bin/perl use strict; use warnings; use Server; my $server = Server->new(); $server->initServer(); # Server.pm
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;
|