Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Replace the nth occurence

by Kenosis (Priest)
on Nov 21, 2012 at 07:22 UTC ( #1004858=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    use strict;
    use warnings;
    ...
    my $str = 'a,b,c,d';
    $str =~ s/(,)/!--$n ? '|' : $1/ge;
    print $str;
    
  2. or download this
    a,b|c,d
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1004858]
help
Chatterbox?
[LanX]: see perlbrew for alternative Perl installations
[marto]: unless you know exactly what you're doing an often saner option is to simply build another Perl rather than replace the system one

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (16)
As of 2017-03-23 10:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (285 votes). Check out past polls.