Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: s///g and capturing all matches

by jethro (Monsignor)
on Dec 15, 2011 at 14:27 UTC ( #943748=note: print w/replies, xml ) Need Help??


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

To quote the documentation of s/// it " returns the number of substitutions made". You made two substitutions, so the result is 2

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

    Hi Jethro,

    and the answer to life, the universe and everything is 42 ;)

    I was wondering why the implementations differ, as well as seeking an ellegant way to get the behaviour I wanted. If s///; returned a list of the items sub'd out then it would be easy enough to use that in scalar contect to have the number. Felt rather un-Perlish to miss out on potential utility.

    Cheers,
    R.

    Pereant, qui ante nos nostra dixerunt!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://943748]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2018-07-17 02:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (353 votes). Check out past polls.

    Notices?