in reply to Global variables

Moreover, this approach is subject to typos as well, because the compiler will accept a call to a function pretty happily.

What's the point you are trying to make here? This issue has nothing to do with global variables, and your only defense here is to not use named subroutines. If you want to use a subroutine you should use a reference to an anonymous function. Note however that if you use 'strict', and call your subroutines without parenthesis, the compile will bark if your subroutine is mistyped. But you can't always easily leave the parenthesis off.

Replies are listed 'Best First'.
Re^2: Global variables
by polettix (Vicar) on Oct 06, 2006 at 09:56 UTC
    What's the point you are trying to make here? This issue has nothing to do with global variables, and your only defense here is to not use named subroutines.
    Well, I'm trying to have fun and learn something ;). Moreover, I was discussing about the opportunity to use named subroutines instead of global variables (I linked this thread in my OP as a start), so I suppose this has to do with global variables.
    If you want to use a subroutine you should use a reference to an anonymous function.
    I'm not able to contextualise this within the discussion. The whole point of using subroutines instead of plain variables is - ehr - not using plain variables. If I have to use anonymous functions, I'm probably obliged to use a variable to carry the reference.

    My consideration was about using functions instead of global variables, and I do agree with you about the fact that the compiler will croak if we try to call them without using parentheses - something along the lines of use constant. On the other side, this would make it difficult (probably not impossible, but I'm no expert here) to use them as variables instead of constants (which is why you probably say that you can't always easily leave the parenthesis off I suppose).

    Flavio
    perl -ple'$_=reverse' <<<ti.xittelop@oivalf

    Don't fool yourself.