Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I believe I mentioned this before somewhere but (probably just in the CB, actually):

BEGIN { $sep= '' } if( '' eq $sep && 1 < @F ) { ( $sep )= /\Q$F[0]\E(.*?)\Q$F[1]\E/; }

Sadly, although join(undef,@F) needn't emit a warning when @F contains fewer than 2 items, it does.

Yes, it still isn't perfect (but I hope it helps some). I'm sure you know where to apply the patch. $^A doesn't appear to be used (for "auto-split separator"), last I checked.

Update: I was trying to think how to wrap this nicely into a module and also that the separator needn't be the same at each point, when I decided the way to do both would be to have the module provide a routine that replaces the old @F values with the new into $_ in-place.

my $pos= 0; for my $f ( 0..$#F ) { pos($_)= $pos; die if ! m/\Q$F[$f]\E/g; $pos= pos($_) + length($G[$f]) - length($F[$f]); substr( $_, $-[0], $+[0]-$-[0], $G[$f] ); } pos($_)= 0;

And I'd also like a module that ties up this trick for avoiding using $& (and capturing) that is also more useful (and faster) than either so I don't have to look up the formula each time. (:

- tye        


In reply to Re: Does Perl 5 (or 6?) need another built-in variable for the -F switch? (re) by tye
in thread Does Perl 5 (or 6?) need another built-in variable for the -F switch? by japhy

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 pondering the Monastery: (5)
As of 2024-04-24 00:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found