'our' gets you a "package global", accessible outside the package via <sigil>PACKAGE_NAME::var_name, or a variable that can be "imported" into your program's namespace.

Hopefully, this code will clarify:
FOO.pm

package FOO; use warnings; use strict; use Exporter 'import'; our @EXPORT_OK = qw/$bar $baz Baz_Get_Set/; our $bar = 42; # Package global, visible as $FOO:bar my $baz = 66; # Not visible outside FOO - needs accessor sub sub Baz_Get_Set{ defined $_[0] and $baz=$_[0]; return $baz; } 1;
pm11149136.pl
use warnings; use strict; use feature 'say'; use lib "."; use FOO qw/$bar $baz Baz_Get_Set/; say "\$bar (an imported 'package' variable)=",$bar; say "\$bar (accessed explicitly via package name \$FOO::bar)=",$FOO::b +ar; $bar="Set via caller"; say "\$bar (accessed explicitly via package name \$FOO::bar after sett +ing via imported var)=",$FOO::bar; say "\$baz (direct attempt to access package 'my` variable)=",$baz; # +This returns UNDEF say "BAZ via getter/setter=",Baz_Get_Set(); # Nothing passed - this is + a GET say "BAZ get after setting to 55=", Baz_Get_Set(55);
OUTPUT:
bash-5.1$ perl pm11149136.pl $bar (an imported 'package' variable)=42 $bar (accessed explicitly via package name $FOO::bar)=42 $bar (accessed explicitly via package name $FOO::bar after setting via + imported var)=Set via caller Use of uninitialized value $baz in say at pm11149136.pl line 11. $baz (direct attempt to access package 'my` variable)= BAZ via getter/setter=66 BAZ get after setting to 55=55
</c>

                "These opinions are my own, though for a small fee they be yours too."


In reply to Re^3: Unclear about 'our' by NetWallah
in thread Unclear about 'our' by ibm1620

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.