develooper Front page | perl.perl6.users | Postings from January 2023

`lines.contains( / \h / )` returning True for input strings notcontaining horizonal whitespace

Thread Next
From:
William Michels via perl6-users
Date:
January 26, 2023 20:05
Subject:
`lines.contains( / \h / )` returning True for input strings notcontaining horizonal whitespace
Message ID:
CAA99HCzajj8XXGZp1ANSzfaQvvvaYYPhbao+cgqeFSLnow=LvA@mail.gmail.com
Hi, I'm seeing an issue where I try to write parallel code between `slurp`
and `lines`, expecting that when I feed each one-liner a string with
vertical whitespace (but not horizontal whitespace), the two methods will
be differentiated--since lines autochomps by default.

~$ raku -e 'put "1\n2\n3";' | raku -e 'put slurp.contains(/ \h /) ?? True
!! False;'
False
~$ raku -e 'put "1\n2\n3";' | raku -e 'put lines.contains(/ \h /) ?? True
!! False;'
True

However, my 'control case' (second example above) is showing that a string
devoid of apparent whitespace is coming up positive, i.e. returning True. I
would think this is a 'trap for the unwary', if it is indeed the specified
behavior.

Comments/feedback welcome and appreciated.
FYI I'm on Rakudo™ v2022.07.

Thx, Bill.

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About