http://qs1969.pair.com?node_id=541665

SamCG has asked for the wisdom of the Perl Monks concerning the following question:



Okay, the code:
perl -e "@re='abcdefg'=~/(..)/g;print join ',', @re;" #prints ab,cd,ef
but, what if I don't want the position to set to after the last match, but to one character after the beginning of the last match to produce ab,bc,cd,de,ef,fg? I've tried a few strange variants of adding code into the expression to alter the 'abcdefg' midway, but these don't seem to produce the results I want.

perl -e "$_='abcdefg';@re=/(..)(?{reverse;chop;reverse;})/g;print join + ',', @re;" ab,cd, perl -e "$_='abcdefg';@re=/(..)(?{$_=substr($_,1)})/g;print join ',', +@re;" bc,ef,
No particular purpose here other than just to wield regexes better, so if there are practical reasons this is ludicrous feel free to tell me.

-----------------
s''limp';@p=split '!','n!h!p!';s,m,s,;$s=y;$c=slice @p1;so brutally;d;$n=reverse;$c=$s**$#p;print(''.$c^chop($n))while($c/=$#p)>=1;