Last active
December 27, 2015 20:59
-
-
Save nonkr/7388344 to your computer and use it in GitHub Desktop.
Perl进阶笔记
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#在package中定义私有函数 | |
#方法一 | |
sub p_func | |
{ | |
caller eq __PACKAGE__ or die; | |
print "test\n"; | |
} | |
#方法二 | |
my $p_func = sub { | |
print "test\n"; | |
}; | |
#========================= | |
my @book = ( | |
"Seek Away", | |
"For True" | |
); | |
my %info = ( | |
"name" => "jason", | |
"age" => 22 | |
); | |
my %guy = ( | |
"book" => \@book, | |
"info" => \%info | |
); | |
#更简洁的写法 | |
my %guy = ( | |
"book" => [ | |
"Seek Away", | |
"For True" | |
], | |
"info" => { | |
"name" => "jason", | |
"age" => 22 | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment