免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3055 | 回复: 1
打印 上一主题 下一主题

二维数组问题 [复制链接]

论坛徽章:
1
技术图书徽章
日期:2016-02-03 16:35:25
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2016-01-19 16:58 |只看该作者 |倒序浏览
#!/usr/bin/perl
@list_of_lists=(
        [qw( mustang bronco ranger)],
        [qw( cavalier suburban buick)],
        [qw( lebaron ram a)],
        [qw( x b c)],
        );


print "$#{$list_of_lists[1]}\n";

$A=scalar(@{$list_of_list[2]});
print "$A\n";


请问$# , scalar这两行分别返回的是什么?如果改变里面的数组对应返回的是什么?

论坛徽章:
145
技术图书徽章
日期:2013-10-01 15:32:13戌狗
日期:2013-10-25 13:31:35金牛座
日期:2013-11-04 16:22:07子鼠
日期:2013-11-18 18:48:57白羊座
日期:2013-11-29 10:09:11狮子座
日期:2013-12-12 09:57:42白羊座
日期:2013-12-24 16:24:46辰龙
日期:2014-01-08 15:26:12技术图书徽章
日期:2014-01-17 13:24:40巳蛇
日期:2014-02-18 14:32:59未羊
日期:2014-02-20 14:12:13白羊座
日期:2014-02-26 12:06:59
2 [报告]
发表于 2016-01-19 17:55 |只看该作者
回复 1# 陈卓文

$ perldoc -f scalar
    scalar EXPR
            Forces EXPR to be interpreted in scalar context and returns the
            value of EXPR.
    ...


$ perldoc perldata
NAME
    perldata - Perl data types

    ...

    Scalar values are always named with '$', even when referring to a scalar
    that is part of an array or a hash. The '$' symbol works semantically like
    the English word "the" in that it indicates a single value is expected.

        $days               # the simple scalar value "days"
        $days[28]           # the 29th element of array @days
        $days{'Feb'}        # the 'Feb' value from hash %days
        $#days              # the last index of array @days

   
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP