摘要: #!/usr/bin/perluse warnings;#use strict强制所有变量必须用my来声明,#当试图使用不是用my声明的裸单词(变量或函数名)时,编译无法通过use strict;#创建简单的hash表my %student = ( "name" => "HuiDong", "id" => 1021400001, "age" => 25,);#对hash表进行操作#返回hash表中的所有keysprint my @key = keys%student;#返回hash表中的所有val 阅读全文
posted @ 2012-04-08 14:17 DreamerHui 阅读(475) 评论(0) 推荐(0) 编辑
摘要: #!/usr/bin/perluse warnings;use strict;#创建数组my @example = ( "name1", "name2", 10, 20,);#输出数组最后一个元素print $example[-1]."\n"; #方式一,常用print $example[$#example]."\n"; #方式二,不常用#获取数组大小my $size_of_example = $#example + 1;#注意:由于数组下表从0开始,因此需要加1print $size_of_example.&qu 阅读全文
posted @ 2012-04-08 14:16 DreamerHui 阅读(631) 评论(0) 推荐(0) 编辑