title: Local and Global variables in perl
body: <p>I am having few doubts about the <code>local/our</code> scope in Perl. I read a lot of documentation, but I am still in confusion is there. Following are the confusions</p>
  <ol>
  <li><p>What is <code>local</code> scope?</p>
  <p>what I read is -&gt; local copies the value of global variable, change the value, user will use it and outside the block it will retain the global value</p>
  <p>Confusion -&gt; <code>my</code> does the same thing. Only benefit I see is that some variables like <code>$package::var</code> cannot be declared with my scope but can be declared with local scope. What else for local</p>
  </li>
  <li><p>What is &quot;global&quot; variable?</p>
  </li>
  </ol>
  <p>What I read is -&gt; Its scope is within the package. Basically we put the global variable in <code>@EXPORT</code> array and use it or append the namespace with it to use in other packages.</p>
  <p>I doubt -&gt; Again if we declare variable with <code>my</code> scope in main only then we can access the variable throughout the package. Is that right? Is it possible to add the <code>my</code> scoped variables in <code>@EXPORT</code> array and use it in another packages?</p>
  <p>I think global variables are declared with <code>our</code> keyword. Is there any other way to do so?</p>
  <p>This question may look repetitive, but I am confused.</p>