my
변수를 만들고 미확정 (스칼라) 또는 빈 (배열과 해시)에 초기화합니다. 또한 생성 한 변수를 반환합니다. 이와 같이
,
print my $simple_variable;
이미이 때문에 펄을 요구하는 이유 당신은 잘 모르겠어요
my $simple_variable = "string";
print $simple_variable;
할 의미
my $simple_variable = undef;
print $simple_variable;
같은 일이 너에게 많이 말했다. 프로그램에서 다음을 출력합니다.
"my" variable $simple_variable masks earlier declaration in same scope at a.pl
line 6 (#1)
(W misc) A "my", "our" or "state" variable has been redeclared in the
current scope or statement, effectively eliminating all access to the
previous instance. This is almost always a typographical error. Note
that the earlier variable will still exist until the end of the scope
or until all closure referents to it are destroyed.
"새로운 인스턴스가 이전 인스턴스에 대한 모든 액세스를 효과적으로 제거"하는 효과에 유의하십시오.
범위 지정에 대해 배웠습니다 !! 더 많은 것을 배우기위한 고전적인 온라인 참고 문헌은 [Coping with Scoping] (http://perl.plover.com/FAQs/Namespaces.html)이고 [PerlMonks 노드] (http://www.perlmonks.org/? node_id = 66677)를 Perl의 가변 스코핑에 적용합니다. –
당신은'print "를 원한다. $ simple_variable \ n";''print'가 자동으로 그 일을하지 않기 때문에'\ n'을 끝에 두어야 만한다. –