title: In Perl, how to share a variable between subroutines, with use strict?
body: <p>If I don't <code>use strict;</code> the following code works fine and prints out "alice":</p>
  
  <pre><code>assign_name();
  print_name();
  
  sub assign_name {
      $name = "alice";
  }
  
  sub print_name {
      print $name;
  }
  </code></pre>
  
  <p>However when I do <code>use strict;</code> then I know I'll have to declare the variable before using it. I read somewhere I should use <code>our</code> instead of <code>my</code> to declare a global variable. So I had the following:</p>
  
  <pre><code>use strict;
  use warnings;
  
  assign_name();
  print_name();
  
  sub assign_name {
      our $name = "alice";
  }
  
  sub print_name {
      print $name;   # This is line 12.
  
  }
  </code></pre>
  
  <p>And then I get the following error:</p>
  
  <pre><code>Variable "$name" is not imported at test.pl line 12.
  Global symbol "$name" requires explicit package name at test.pl line 12.
  Execution of test.pl aborted due to compilation errors.
  </code></pre>
  
  <p>Please help.</p>