in reply to s///g and capturing all matches

:D Because m// and s/// are different operators that behave differently :D

s/// always returns the number of matches, unless you use /r, in which case it returns a string copy see perlop#s/PATTERN/REPLACEMENT/msixpodualgcer

my @c; s/(...)/ push @c, $1; q[X]; /ge

Replies are listed 'Best First'.
Re^2: s///g and capturing all matches
by Random_Walk (Prior) on Dec 16, 2011 at 09:08 UTC

    thank you anonymonk, very ellegant. I had forgoton the use of code in the RHS was possible.

    Cheers,
    R.

    Pereant, qui ante nos nostra dixerunt!