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)
In reply to GLOBAL VARIABLE HANDLING by kaushal_k1
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |