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

It's easy to manufacture example code that shows something like the behavior you report:

c:\@Work\Perl\monks>perl -wMstrict -le "my $x; ;; S('A'); ;; $x = 'foo'; ;; S('B'); ;; sub S { print qq{$_[0]: x is }, defined $x ? qq{'$x'} : 'undefined'; +} " A: x is undefined B: x is 'foo'
This simple example code always produces the output shown. It's easy to imagine that in your "much more complex" code different execution paths are sometimes taken, such that your equivalent of  $x has, on occasion, already been initialized when subroutine  S() is called at point 'A'. In any event, I hope it is clear why  $x is uninitialized at point 'A' and initialized at point 'B'.

Update: See also the discussion in response to subroutine no error.

Replies are listed 'Best First'.
Re^2: Basic mod-perl question : why my variable is undefined ?
by pcouderc (Monk) on Jul 23, 2014 at 14:44 UTC
    Thank you. This is clear, but it is not my problem. And this is not mod-perl. The point is "sometimes", not "always".