On 2/19/2010 3:29 PM, Barry Brevik wrote:
> I was under the impession that when I use the keyword "our" when
> declaring a variable, that the variable was then available to
> subroutines called from the routine that declared the variable.
>
> However, the code shown below fails with the following message:
>
> Variable "$clr" is not imported at test5.pl line 17.
> Global symbol "$clr" requires explicit package name at test5.pl line 17.
>
> What gives?
>
> -Barry Brevik
>
> ===================================
> use strict;
> use warnings;
>
> my $color = 'blue';
>
> setColor($color);
>
>
> sub setColor
> {
>    our $clr = $_[0];
>    adjustColor();
> }
>
> sub adjustColor
> {
>    print "$clr\n";
> }
>
>


http://perldoc.perl.org/functions/our.html   --

"In other words, our has the same scoping rules as my, but does not 
necessarily create a variable."

...so, it's more like a static variable from the c world.  I think you 
might be thinking of 'local'.
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to