in reply to Re: Stupid question
in thread Stupid question

Thanks, that helps.

Is that considered a 'good' format, or should I just not worry about the subroutines access to these variables?

Replies are listed 'Best First'.
(jeffa - data hiding) Re: Re: Re: Stupid question
by jeffa (Bishop) on Dec 07, 2000 at 02:51 UTC
    I personally think that 'main' variables, while able to be accessed by subroutines declared in the same package, are safe enough, as long as you don't access them directly in a subroutine.
    use strict; my $foo = 'yo'; &bar($foo); print "$foo\n"; sub bar { my $bar = shift; $bar .= ' dude'; }
    Declare you variables in main, just don't use them directly in your subroutines and you'll be okay.

    Jeff

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    F--F--F--F--F--F--F--F--
    (the triplet paradiddle)
    
Re: Re: Re: Stupid question
by chipmunk (Parson) on Dec 07, 2000 at 02:52 UTC
    If you are worried about the subroutines accessing these variables, this is the way to avoid the problem; go for it! It is a good programming practice to have subroutines get all their input through the argument list and not through external variables, because it makes the code more maintainable.