Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Selective substitution: not in Perl?

by Anonymous Monk
on Aug 16, 2000 at 13:19 UTC ( [id://28079]=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    @foos = split(/(?=foo)/, 'foo' x 4);
    $foos[1] = 'bar';
    ...
        $_ .= $elem;
    }
    print;
    
  2. or download this
    $_ = 'foo' x 4;
    for(map { ++$i == 2 ? 'bar' : $_ } split(/(?=foo/, $_))
    ...
        $result .= $_;
    }
    print $result;
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2024-04-24 07:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found