Perl assignment with a dummy placeholder

后端 未结 4 2243
北恋
北恋 2020-12-18 17:51

In other languages I\'ve used like Erlang and Python, if I am splitting a string and don\'t care about one of the fields, I can use an underscore placeholder. I tried this

4条回答
  •  遥遥无期
    2020-12-18 18:48

    undef serves the same purpose in Perl.

    (undef, $something, $otherthing) = split(' ', $str);
    

提交回复
热议问题