Re: Getting a / when regex should produce nothing

Perrin Harkins <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <[email protected]>
On Tue, Apr 27, 2010 at 2:08 PM, Michael Ludwig <[email protected]> wrote:
> Variables declared with "our" are a funny hybrid between global
> variables, which are attached to a package, and lexical variables,
> which are attached to a scope.

They are package variables (usually referred to as globals), which
have a lexically-scoped alias that lets you call them by their short
name.  It's the short name alias that is lexical.

Here's a normal use of a package variable:

package Foo;
use strict;
use warnings;

$Foo::bar = 1;

sub print_it {
    print $Foo::bar;
}

And here's the exact same thing, using "our" to save some typing:

package Foo;
use strict;
use warnings;

our $bar;
$bar = 1;

sub print_it {
    print $bar;
}

Aside from the difference in how you refer to the variable, these are identical.

Hope that helps.  If it doesn't, try this:
http://perldoc.perl.org/functions/our.html

- Perrin
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.