chomp in perl not working as expected

前端 未结 4 1727
逝去的感伤
逝去的感伤 2021-01-14 06:33

I found a strange behavior of chomp in Perl and I am unable to comprehend why is chomp is working like this.

The following line does not work as expected

<         


        
4条回答
  •  -上瘾入骨i
    2021-01-14 06:53

    I like the name chomp() it's sound tells you what it does. As @ruakh mentions it takes one or more arguments, so you can say:

    chomp($str1,$str2);
    if ( $str1 eq $str2 ) ...
    

    You can also hand it an array of strings, like what you would get from reading a whole file at once, e.g.:

    chomp(@lines);
    

提交回复
热议问题