in reply to Can I get some help with a regex please

#!/usr/bin/perl use warnings; use strict; my $block = "cat\nman\n"; my $n = 3; my $expected = << '__EOF__'; 1 cat man 2 cat man 3 cat man __EOF__ $block =~ s/(cat\nman\n)/join "", map "$_ $1", 1 .. $n/e; use Test::More tests => 1; is $block, $expected, 'same';
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Replies are listed 'Best First'.
Re^2: Can I get some help with a regex please
by misterperl (Friar) on Jun 13, 2023 at 16:02 UTC
    nicely done, but it's none too pretty! I voted you ++ . I was hoping for some built-in DUP functionality on the RHS like \1{$n} or something?