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

Re: $/ not always set after a regex match?

Thread Previous | Thread Next
From:
William Michels via perl6-users
Date:
January 1, 2023 00:57
Subject:
Re: $/ not always set after a regex match?
Message ID:
CAA99HCwTVYDmmaLsRGZ7O506KHZPZzRG-kmyA-YiRjjUzQQ+qw@mail.gmail.com
Interested in answering the question:

WHICH CODE EXAMPLE IS THE PRETTIEST?

Vote for your favorite (or post your own):

[#] > #REPL (line numbers altered to differentiate)
Nil
[0] > $_ = 'gracefully'
gracefully
[1a] > put "The root of $_ is $/." if / .+ <before ly> /;
The root of gracefully is graceful.
[1b] > put "The root of $_ is $<>." if / .+ <before ly> /;
The root of gracefully is graceful.
[1c] > print "The root of $_ is " andthen put $/ ~ '.' if / .+ <?before ly>
/;
The root of gracefully is graceful.
[1d] > print "The root of $_ is " andthen put $<> ~ '.' if / .+ <?before
ly> /;
The root of gracefully is graceful.
[1] >
[2a] > put "Or is the root of $_ $/?" if / .+ <before full> /;
Or is the root of gracefully grace?
[2b] > put "Or is the root of $_ $<>?" if / .+ <before full> /;
Or is the root of gracefully grace?
[2c] > print "Or is the root of $_ " andthen put $/ ~ '?' if / .+ <?before
full> /;
Or is the root of gracefully grace?
[2d] > print "Or is the root of $_ " andthen put $<> ~ '?' if / .+ <?before
full> /;
Or is the root of gracefully grace?
[#] >


On Fri, Dec 30, 2022 at 1:44 PM Sean McAfee <eefacm@gmail.com> wrote:

> On Fri, Dec 30, 2022 at 4:12 PM The Sidhekin <sidhekin@gmail.com> wrote:
>
>> On Fri, Dec 30, 2022 at 8:51 PM Vadim Belman <vrurg@lflat.org> wrote:
>>
>>> It is not "untrue". The sequence you produced goes nowhere. Thus the
>>> sink context.
>>>
>>
>>   "Sink context" is true.
>>
>>   "Useless use" is debatable, at least.
>>
>
>  It's not useless because there's a side effect: setting $/.
>
>

Thread Previous | 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