in reply to Unintialised value?
If you use strict; use warnings; whenever you try to compare an undefined value it will yelp. This is great to do, but if you want to fix that warning you should let perl know you expect the possibility of an undef value by testing for an undef value (and only performing concatanation, regular expressions, or anything else with it) if it's defined, i.e.:
# note that we have to check if its defined # because it's possible it could be 0, and false #62 exit 0 unless ((defined ($page)) and (defined($pages{$page})) and ($pages{$page} == '1'));
You should note that you are shifting from @_ to set $page == undef; especially on this little bit of test code. So if @_ is undefined then you'll get those warnings. You can turn off warnings for uninitialized values by using:
NOWHINING: { no warnings qw (uninitialized); my %pages = ("index" => '1', "me" => '1', "stuff" => '1', "links" => '1'); my $page = shift; exit 0 unless $pages{$page} == '1'; }
Just be careful with the above code because:
Good luck!
Vautrin
|
|---|