Practical mod_perl / HTML Book /



previous page: 22.3.6. Global symbol "$foo" requires explicit package name
  
page up: HTML Version of the book
  
next page: 22.3.8. Undefined subroutine &Apache::ROOT::perl::test_2epl::some_function called at

22.3.7. Use of uninitialized value at (eval 80) line 12


If you see this message, your code includes an undefined variable that you have used as if it was already defined and initialized. For example:

my $param = $q->param('test');
print $param;

You can fix this fairly painlessly by just specifying a default value:

my $param = $q->param('test') || '';
print $param;

In the second case, $param will always be defined, either with $q->param('test')'s return value or the default value the empty string ('' in our example).

 

Continue to:

  • prev: 22.3.6. Global symbol "$foo" requires explicit package name
  • Table of Contents
  • next: 22.3.8. Undefined subroutine &Apache::ROOT::perl::test_2epl::some_function called at







TOP
previous page: 22.3.6. Global symbol "$foo" requires explicit package name
  
page up: HTML Version of the book
  
next page: 22.3.8. Undefined subroutine &Apache::ROOT::perl::test_2epl::some_function called at


Menu

  • HTML Book
  • PDF Book
  • Download Code
  • Table of Contents
  • Errata
  • mod_perl2 User's Guide
  • Sitemap

Search


Add to Google




Creative Commons License


Written by
Eric Cholet (Logilune) and
Stas Bekman (StasoSphere & Free Books).


[ Privacy Policy | Terms of Use | About Us | Search ]

© 2007 StasoSphere.com