Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^5: Unusual variable declaration

by Jenda (Abbot)
on Nov 05, 2019 at 11:19 UTC ( #11108320=note: print w/replies, xml ) Need Help??


in reply to Re^4: Unusual variable declaration
in thread Unusual variable declaration

The point is that our is not doing the same thing. Not even basically. It might look like it does if you use it once, but as soon as you have several ours for the same variable in separate blocks it's clear our is not doing anything like my.

Jenda
1984 was supposed to be a warning,
not a manual!

Replies are listed 'Best First'.
Re^6: Unusual variable declaration
by LanX (Archbishop) on Nov 05, 2019 at 12:27 UTC
      package Foo; $Foo::y = 42; sub foo { my $x; our $y; ... } sub bar { my $x; our $y; ... }

      Each of the two my $x declares a new variable. Both the our $y instruct the compiler to allow you to temporarily use a short name for the same global variable. They do NOT declare a variable!

      Jenda
      1984 was supposed to be a warning,
      not a manual!

        > > Please define "declaration"

        > They do NOT declare a variable!

        Not a definition.

        You are effectively saying reiterating again and again that my and our have differences and are using my as your personal standard for declaration.

        I'm tired of this.

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11108320]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2020-05-29 01:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (166 votes). Check out past polls.

    Notices?