Re: Perl realted..?



On Jan 10, 2008 1:23 PM, Chris Howie <cdhowie@xxxxxxxxx> wrote:
On Jan 10, 2008 1:11 PM, ISHWAR RATTAN <rattan@xxxxxxxxxxxxx> wrote:

I am coming back to perl after a long time.

The sample code these days also uses variable attribute my as:

my $inst = Extutils::Installed->new();
my @modules = $inst->modules();

Can any demistify 'my' for me??

-ishwar


"my" declares a variable that exists within the current scope and is
unreachable from outside the scope. So a "my" declaration in one package
cannot be reached from another package. "our" is identical to "my" except
that you *can* reach that variable from other packages. A "my" declaration
inside of a function just limits the scope and lifetime of the variable to
that function.

I just wanted to point out that to take full advantage of "my" you
might want to program using "use strict" also.

N.-

--
http://arhuaco.org


--
To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx
with a subject of "unsubscribe". Trouble? Contact listmaster@xxxxxxxxxxxxxxxx



Relevant Pages

  • Re: Perl realted..?
    ... The sample code these days also uses variable attribute my as: ... Can any demistify 'my' for me?? ... "my" declares a variable that exists within the current scope and is ... unreachable from outside the scope. ...
    (Debian-User)
  • Re: typedef and static
    ... Well of course functions cannot have function scope. ... An identifier is visible only within a region ... declarator or type specifier that declares the identifier appears ...
    (comp.lang.c)
  • Variable Scope in Include Files
    ... file that declares a constant DAY_NUM. ... but then I get a new one where index.php refers to ... I was assuming that any constant had global scope and therefore when I ...
    (comp.lang.php)
  • Re: OT: C++ help
    ... Overload ambiguities are resolved in scope, ... suspect a bug in gcc. ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)
  • Re: OT: C++ help
    ... (Declaration Matching). ... "A function member of a derived class is ... There's no fin scope, ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)