免费注册 查看新帖 |

Chinaunix

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

对$$如何理解 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2015-02-01 13:31 |只看该作者 |倒序浏览
$是声明一个变量

$$是变量的变量吗?

它和c语言的* 指针 **指针的指针是不是一个意思?

论坛徽章:
3
2015亚冠之阿尔希拉尔
日期:2015-08-15 16:33:2215-16赛季CBA联赛之四川
日期:2016-01-03 13:37:0515-16赛季CBA联赛之四川
日期:2016-06-13 15:53:36
2 [报告]
发表于 2015-02-01 13:56 |只看该作者
本帖最后由 minirain 于 2015-02-01 13:57 编辑
bandaotidejia 发表于 2015-02-01 13:31
$是声明一个变量

$$是变量的变量吗?


用命令:perldoc perlvar 可以查寻得到帮助如下:
  1. \$\$      The process number of the Perl running this script. Though you
  2.             *can* set this variable, doing so is generally discouraged,
  3.             although it can be invaluable for some testing purposes. It will
  4.             be reset automatically across "fork()" calls.

  5.             Note for Linux and Debian GNU/kFreeBSD users: Before Perl
  6.             v5.16.0 perl would emulate POSIX semantics on Linux systems
  7.             using LinuxThreads, a partial implementation of POSIX Threads
  8.             that has since been superseded by the Native POSIX Thread
  9.             Library (NPTL).

  10.             LinuxThreads is now obsolete on Linux, and caching "getpid()"
  11.             like this made embedding perl unnecessarily complex (since you'd
  12.             have to manually update the value of $), so now $ and
  13.             "getppid()" will always return the same values as the underlying
  14.             C library.

  15.             Debian GNU/kFreeBSD systems also used LinuxThreads up until and
  16.             including the 6.0 release, but after that moved to FreeBSD
  17.             thread semantics, which are POSIX-like.

  18.             To see if your system is affected by this discrepancy check if
  19.             "getconf GNU_LIBPTHREAD_VERSION | grep -q NPTL" returns a false
  20.             value. NTPL threads preserve the POSIX semantics.

  21.             Mnemonic: same as shells.
复制代码

论坛徽章:
0
3 [报告]
发表于 2015-02-01 16:27 |只看该作者
这不是我想要的答案 比如
  $abc= {};
  $$abc{"par1"} = {};
  $$abc{"par2"}     = {};
  $$abc{"par3"}       = {};

很明显就是二维的概念

论坛徽章:
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
4 [报告]
发表于 2015-02-02 11:14 |只看该作者
回复 3# bandaotidejia

Here you are


$ perldoc perldata
NAME
    perldata - Perl data types
...


$ perldoc perlref
NAME
    perlref - Perl references and nested data structures
...

论坛徽章:
0
5 [报告]
发表于 2015-02-02 14:17 |只看该作者
所以说,2楼说的不对

论坛徽章:
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
6 [报告]
发表于 2015-02-02 16:19 |只看该作者
本帖最后由 jason680 于 2015-02-02 16:20 编辑

回复 5# bandaotidejia

>>所以说,2楼说的不对

也有可能是,你问的不对...
$$本身就是perl的特殊变量

$ perldoc perlvar
NAME
    perlvar - Perl predefined variables
...

    $PROCESS_ID
    $PID
    $$
     The process number of the Perl running this script. You should
            consider this variable read-only, although it will be altered
            across "fork()" calls.

            Note for Linux users: on Linux, the C functions "getpid()" and
            "getppid()" return different values from different threads. In
            order to be portable, this behavior is not reflected by $$, whose
            value remains consistent across threads. If you want to call the
            underlying "getpid()", you may use the CPAN module "Linux::Pid".

            Mnemonic: same as shells.

   

论坛徽章:
0
7 [报告]
发表于 2015-02-02 16:47 |只看该作者
我说的很明白了 $是。。。 $$是什么

我没问$$本身

但凡学过perl的 应该知道哪个更不好理解

论坛徽章:
0
8 [报告]
发表于 2015-02-02 17:54 |只看该作者
$本身是一个scalar,$$就是解引用获得引用的scalar。

论坛徽章:
1
2015年辞旧岁徽章
日期:2015-03-03 16:54:15
9 [报告]
发表于 2015-02-04 09:23 |只看该作者
回复 5# bandaotidejia


    尼玛,合着你来上 ChinaUnix 就是为了证明别人不对来的?
人家辛辛苦苦贴那么多又是找材料又是排版,回头你说人家不对?
读书读傻了吧你?

论坛徽章:
3
2015亚冠之阿尔希拉尔
日期:2015-08-15 16:33:2215-16赛季CBA联赛之四川
日期:2016-01-03 13:37:0515-16赛季CBA联赛之四川
日期:2016-06-13 15:53:36
10 [报告]
发表于 2015-02-05 11:28 |只看该作者
本帖最后由 minirain 于 2015-02-07 10:51 编辑
flw 发表于 2015-02-04 09:23
回复 5# bandaotidejia

支持版主,有些人提问有问题,还自以为是!
解气!!!
本来$$与$$abc是两个不同范畴:
1、$$是特殊变量;
2、$$abc看过引用人都知道$$abc是解引用,知道$abc是标量引用或者提问者的$abc{'xyz'}为用哈希储存标量引用,如:$abc{'xyz'} =\$X;
那么$$abc{'xyz'}=$X。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP