Advertisement
hakonhagland

modules-perl-our

Sep 22nd, 2021
1,509
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.56 KB | None | 0 0
  1. # The file module1.pm :
  2.  
  3. package module1;
  4. use strict;
  5. use warnings;
  6. use module2;
  7. sub print_var {
  8.     print "global_var1 = ", $module2::global_var1, "\n";
  9. }
  10. 1;
  11.  
  12. ----------------------------------
  13.  
  14. # The file module2.pm :
  15.  
  16. package module2;
  17. use strict;
  18. use warnings;
  19. our $global_var1 = 'global_var_sub';
  20. 1;
  21.  
  22. ------------------------------
  23.  
  24. # The main script:
  25.  
  26. use strict;
  27. use warnings;
  28. use lib '.';
  29. use module1;
  30. module1::print_var();
  31.  
  32.  
  33. -----------------------------------
  34.  
  35. # Output from running the main script:
  36.  
  37. global_var1 = global_var_sub
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement