Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: Please tell me the meaning of this code.

by cLive ;-) (Parson)
on Jul 01, 2007 at 09:34 UTC ( #624284=note: print w/replies, xml ) Need Help??

in reply to Please tell me the meaning of this code.

Change the 5th occurrence of whoever/whomever in $_ to whosoever/whomsoever. Here's a little more detail in a slight rewrite:
my $count=0; $_ =~ s/ ((whom?)ever) # whom? is in $2, whom?ever is in $1 / if ( ++$count == 5 ) # for the fifth match { "${2}soever"; # set to whom?soever } else { $1; # leave it as it is } /igex; # case (i)nsensitive, (g)lobal match, (e)xecute replace +string. # (x) ignore whitespace (added for this code example)
ps - I hope your tutor reads Perlmonks :)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://624284]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (17)
As of 2016-10-27 15:16 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (365 votes). Check out past polls.