Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Non-greedy substitution

by tybalt89 (Monsignor)
on Nov 15, 2024 at 20:42 UTC ( [id://11162740]=note: print w/replies, xml ) Need Help??


in reply to Non-greedy substitution

Just because I've never seen 'reductions' used before :)

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11162727 use warnings; use List::Util qw( reductions ); use Data::Dump 'dd'; dd map s/.*\K,/ and/r, reductions { "$a, $b" } 'A'..'Z';

Outputs:

( "A", "A and B", "A, B and C", "A, B, C and D", "A, B, C, D and E", "A, B, C, D, E and F", "A, B, C, D, E, F and G", "A, B, C, D, E, F, G and H", "A, B, C, D, E, F, G, H and I", "A, B, C, D, E, F, G, H, I and J", "A, B, C, D, E, F, G, H, I, J and K", "A, B, C, D, E, F, G, H, I, J, K and L", "A, B, C, D, E, F, G, H, I, J, K, L and M", "A, B, C, D, E, F, G, H, I, J, K, L, M and N", "A, B, C, D, E, F, G, H, I, J, K, L, M, N and O", "A, B, C, D, E, F, G, H, I, J, K, L, M, N, O and P", "A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P and Q", "A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q and R", "A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R and S", "A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S and T", "A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T and U", "A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U and V +", "A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V an +d W", "A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W + and X", "A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W +, X and Y", "A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W +, X, Y and Z", )

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11162740]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2025-11-13 12:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (69 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.