Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Re: Re: Replacing a given character starting with the xth occurence in a string

by Anonymous Monk
on May 21, 2001 at 10:50 UTC ( [id://81928]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Replacing a given character starting with the xth occurence in a string
in thread Replacing a given character starting with the xth occurence in a string

You're right of course, my code should have been:

#!/usr/bin/perl -w my $p = 'Terrence and Philip are sweet'; $p =~ s/e/1/g; print "$p";

which is a direct copy and paste, but still doesn't give the desired result, I see after re-reading. I'll have to think about that a little harder. Now I see why it wasn't as easy as I thought at first go.

sharle

  • Comment on Re: Re: Re: Replacing a given character starting with the xth occurence in a string
  • Download Code

Replies are listed 'Best First'.
Re: Re: Re: Re: Replacing a given character starting with the xth occurence in a string
by davorg (Chancellor) on May 21, 2001 at 15:37 UTC

    Also worth noting that for single character translations like this, tr/// is much more efficient than s///.

    --
    <http://www.dave.org.uk>

    "Perl makes the fun jobs fun
    and the boring jobs bearable" - me

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-18 18:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found