加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

Perl赋值与虚拟占位符

发布时间:2020-12-15 21:21:54 所属栏目:大数据 来源:网络整理
导读:在其他语言中,我使用像Erlang和Python,如果我分割一个字符串,而不关心其中一个字段,我可以使用一个下划线占位符。我在Perl中尝试过: (_,$id) = split('=',$fields[1]); 但我得到以下错误: Can’t modify constant item in list assignment at ./genera
在其他语言中,我使用像Erlang和Python,如果我分割一个字符串,而不关心其中一个字段,我可以使用一个下划线占位符。我在Perl中尝试过:
(_,$id) = split('=',$fields[1]);

但我得到以下错误:

Can’t modify constant item in list assignment at ./generate_datasets.pl line 17,near “);”
Execution of ./generate_datasets.pl aborted due to compilation errors.

Perl有类似的这样的模式,我可以使用而不是创建一个无用的临时变量?

解决方法

undef在Perl中具有相同的用途。
(undef,$something,$otherthing) = split(' ',$str);

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读