I like statement modifiers, though not so much using side-effect variables
set by a postfix modifier, I'd like to see the side effect before seeing
the variable it sets. Something like

/ .+ <?before ly> / && put "The root of $_ is $/.";

though the discussion is about not setting $/ in the caller's context and
I'm not sure how to rewrite it with the matching operation first and
passing the match result to a named variable and also skipping if no match,
all in a single statement.

-y


On Sat, Dec 31, 2022 at 8:10 PM William Michels via perl6-users <
perl6-users@perl.org> wrote:

> RESENDING: The code examples below should read `<?before ...>` in all
> cases, not `<before ...>`, although either works (erroneously?).
>
> -------------------
>
> 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?
> [#] >
>
>

Reply via email to