Before writing this program,I thought that our
is a package scope variable and my
is
a file scope variable.But,After did that program,I am get confused.
我的节目是,
#!/usr/bin/perl
use strict;
use warnings;
package one;
our $val = "sat";
my $new = "hello";
print "ONE:val =>$val
";
print "ONE:new =>$new
";
package two;
print "TWO:val =>$val
";
print "TWO:new =>$new
";
产出数
ONE:val =>sat
ONE:new =>hello
TWO:val =>sat
TWO:new =>hello
那么,my
和our
之间有什么区别? 两者是相同还是有区别?