Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I love all of the answers to this question, especially ZZamboni's, satchmet's and tachyon's.
I went over and said to @coworker, "lookie this!", and they replied "what the hell does that do?"
I explained what the topic was.
$coworker[1] says "ah, that's faboo, but how does it do it?" and it took me about 5 minutes to puzzle through ZZamboni's. He explained that the idea's useful, but the implementation was a bit opaque for him. We chatted for a few more, and then I suggested the following, which is a much different take.
use strict; my $s=n_sub ("Toy boats are for the little boys" ,2,"b","g"); $s=n_sub ($s,4,"o","i"); $s=n_sub ($s,2,"y","rl"); print $s; sub n_sub { my ($os, $xth, $ic, $oc) = @_; my @el= split /$ic/,$os, $xth; $el[-1] =~ s/$ic/$oc/g; return join ($ic, @el); }
I don't suggest that this may be a faster implementation, or a better one, but for those that I showed, it's more understandable.
I'm not knocking anyone's reg-fu, of course, but even some basic concepts like ?: confound some, and I wanted to show TIMTOWTDI.


on a related subject, isn't this concept called lookbehind, as in the owl, pg 229 and 230?

In reply to (boo) Re: Replacing a given character starting with the xth occurence in a string by boo_radley
in thread Replacing a given character starting with the xth occurence in a string by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2024-04-23 19:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found