develooper Front page | perl.perl5.porters | Postings from July 2012

Re: [perl #113974] package NAMESPACE manpage comments

Thread Previous | Thread Next
From:
Eric Brine
Date:
July 6, 2012 08:28
Subject:
Re: [perl #113974] package NAMESPACE manpage comments
Message ID:
CALJW-qEDycXsBS+e+VEsi_-BkHMOrtH35uAzovbLv4DVtw__ZA@mail.gmail.com
On Fri, Jul 6, 2012 at 11:20 AM, demerphq <demerphq@gmail.com> wrote:

> > Not so. Equally new var there. A variable is an association between a
> name
> > and an address. "state", "our", and "my" equally create variables.
>
> our doesnt create anything.
>

Yes it does:

>perl -E"$x = 123; package Foo; say $x"

>perl -E"our $x = 123; package Foo; say $x"
123

It creates a lexically-scoped variable which is identical to $main::x (in
the above example). Remember, a variable is an association between a name
and storage. "our" does exactly that.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About