in reply to Basic mod-perl question : why my variable is undefined ?

Write code like this, create subs that take arguments , subs that don't work on global variables, its good practice everywhere and especially for registry , see CGI to mod_perl Porting. mod_perl Coding guidelines, see sub DebugCGI in UTF-8

Main( @ARGV ); exit( 0 ); sub Main { my $lig = 4; my $q = CGI->new; DoSomething( $lig, $q ); } sub DoSomething { my( $lig, $q ) = @_; ... }

Also, Basic debugging checklist , brian's Guide to Solving Any Perl Problem, CGI Help Guide , Troubleshooting Perl CGI scripts, CGI to mod_perl Porting. mod_perl Coding guidelines

Tutorials: Variable Scoping in Perl: the basics,
Coping with Scoping , Mini-Tutorial: Perl's Memory Management,
Lexical scoping like a fox,
Read this if you want to cut your development time in half!,
Closure on Closures , perlref#Circular References,
Memory leaks and circular references,
Circular references and Garbage collection.,
make perl release memory,
about memory management , Re^3: Scope of lexical variables in the main script , Re: What's the weaken here for?,
Devel::Cycle,
Devel::NYTProf,
Devel::Leak Devel::LeakTrace,
WeakRef

Basic debugging checklist and brian's Guide to Solving Any Perl Problem ) ... On debugging, verify everything, talk to teddybear ... checklists and more, Re^3: A Beginner Needs Homework help

Replies are listed 'Best First'.
Re^2: Basic mod-perl question : why my variable is undefined ?
by pcouderc (Monk) on Jul 23, 2014 at 11:38 UTC
    Thenk you,
    1- You give me very muche reading. Thank you. I have read most of that many times and I am lost in it, and this is the reason that I ask.
    2- OK, I know that there are problems with global variable. Sure I can declare $lig in the sub. But my question is generic : why it does not work ?