use strict; use warnings; A::func(); #### use Exporter; @EXPORT = qw ($guimodule); my $mw = MainWindow->new(); sub func { $guimodule = GuiModule->new(parentWnd => $mw); $guiModule->initGui(); #constructs some columns of hlist $guimodule->populateGui(); #populate the tree forks receiver.pl forks sender.pl } 1; #### sub new { .... $self = {parentWnd=> $args{parentWnd}; } sub initGui { # creates other attributes as $self->{tree} = ... } sub populateGui { ...} sub changeGui { ## changeGui is getting invoked from Server::initServer() ## but $self->{tree} coming as undefined but before forking ## these two process Dumper($self) is having the expected ##hash structure } 1; #### my $s = Server->new(); $s->initServer(); #### use A; sub new { $class = shift; my $self = { .... }; bless $self; return $self ; } sub initServer { # starts the server using IO::Socket::INET ## accepts the connection if ($socket readable) { $guimodule->changeGui(); } } 1;