[JOB] Perl Software Developer and Database programmer

Jonathan Stowe jns at gellyfish.com
Wed Feb 22 14:44:47 GMT 2006


On Wed, 2006-02-22 at 11:52, Peter Corlett wrote:

> I've yet to find a real use for our, apart from that it's better than "use
> vars" for declaring globals. I can't help thinking I'm missing some other
> obvious use for it, but I'm not sure what.

The effect is lexically rather than package scoped, thus helps to
prevent you from getting stuffed up by a package scoped 'declaration' in
another file. On the other hand the beahviour of:


        use Varsour;
        use strict;
        
        package Foo;
                                                                        
        print $foo;
                                                                        
        package Zub;
                                                                       
        print $foo;
        
Varsour.pm:

        use strict;
                                                                                        
        package Foo;
                                                                                        
        use vars qw($foo);
                                                                                        
        $foo = 'tataat';
                                                                                        
        1;

Could actually be considered useful in some circumstances. Similar to
the local/my thing it would probably be a bit strong to say that 'our'
obseletes 'use vars' as it introduces a different behaviour.

/J\
-- 

This e-mail is sponsored by http://www.integration-house.com/



More information about the london.pm mailing list