kaushal_k1 has asked for the wisdom of the Perl Monks concerning the following question:
now when i do perl -e 'use mypkg;' i get error saying can't call get on undefined value. if I put a condition saying if defined as shown in the commented line above it works fine.But the problem is "get()" gets called plenty of times in different modules.Can't add check everywhere. Is there a clean way to handle this scenario.package mypkg; use vars qw (@ISA @EXPORT); @ISA =qw(Exporter); @EXPORT = qw( $GLOBALVARREF); our GLOBALVARREF = undef; sub new { GLOBALVARREF is intiliazed to $self. } sub get { return $someval{shift}; } pkg B; use mypkg; my $val = $GLOBALVARREF->get{'NAME'}; #my $val = $GLOBALVARREF->get{'NAME'} if defined($GLOBALVARREF)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: GLOBAL VARIABLE HANDLING
by Corion (Patriarch) on Jul 26, 2011 at 11:53 UTC | |
by kaushal_k1 (Novice) on Jul 26, 2011 at 15:03 UTC | |
|
Re: GLOBAL VARIABLE HANDLING
by Anonymous Monk on Jul 26, 2011 at 11:52 UTC | |
by kaushal_k1 (Novice) on Jul 26, 2011 at 14:29 UTC |