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", )

In reply to Re: Non-greedy substitution by tybalt89
in thread Non-greedy substitution by Bod

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.