in reply to Re: conditional definition of variables
in thread conditional definition of variables

Thanks, betterworld.
Your proposal works.
When you say a variable should not be defined more than once in a block - I did not think I did that in the code as the second declaration is conditional to the variable not being defined.
Am I missing anything here?
  • Comment on Re^2: conditional definition of variables

Replies are listed 'Best First'.
Re^3: conditional definition of variables
by JavaFan (Canon) on Aug 23, 2008 at 14:38 UTC
    "Definition" (or declaration) of the variable happens at compile time. The conditional happens at run time.

    So, if you have

    my $var = "..." if EXPR;
    you will have all the compile time effects, and maybe the runtime effects. This was abused (with 'EXPR' being 0) to get "state" variables in 5.8 and before (which didn't always 'work'), which in turn let to the "state" keyword in 5.10.