数组变量以 @ 符号开始,元素放在括号内
简单举例如下
perl
#!/usr/bin/perl
@names = ("a1", "a2", "a3");
print "\$names[0] = $names[0]\n";
print "size: ",scalar @names,"\n";
$new_names = shift(@names);
print "\@names = @names\n"."弹出元素为 :$new_names\n";
$namess = "a1,a2,a3";
@namess = split(',', $namess);
print "@namess\n";
运行结果如下所示
Perl中哈希变量以百分号 (%) 标记开始
访问哈希元素格式:${key}
简单举例如下
perl
#!/usr/bin/perl
%data = ('google', 'google.com', 'runoob', 'runoob.com', 'taobao', 'taobao.com');
print "\$data{'google'} = $data{'google'}\n";
@names = values %data;
print "$names[0]\n";