in reply to Re: unexpected behavior with split
in thread unexpected behavior with split

ikegami:
Bingo! ...and thank you!

$rest = "\n\t" . $new; #see ikegami's reply; was ". $aphor"

Now I will give both your alt solutions the study they deserve (something, I've been holding off on in hopes I could find my own errors).

I think I understand the underlying difference in approach lies in your design of REMOVING the matches from the front of $new, so each iteration has to start the count at an appropriate point while my

@new = $rest =~ m/\G(.{$min,$max}[\x20.])?/gsx;

is either
a) an abuse of \G (owls, p15 sez "Beginning of current search" (emphasis supplied) whereas I (mis)read other docs to imply that it reset the start of the search
or...
b) use of the "?" quantifier is wrong.

And even if neither of those proves out, many thanks, both for the wisdom imparted and the implicit encouragement.

Replies are listed 'Best First'.
Re^3: unexpected behavior with split
by ikegami (Patriarch) on Aug 31, 2004 at 20:57 UTC

    I didn't use \G as a way of avoid using $'. I could have come up with a way of using \G and not using $', but I chose this way.

    I did get rid of $max+6. It makes no sense. I think it was added as a hack to make $min look like it's working better than it really does. In fact, $min is totally useless unless you force a break mid-word whern there is no space between pos $min and $max (which you don't do). Until $min's function is better defined, I just dropped it completely from my version. I suppose s/^(.{$min,$max2}\S)\s+//s would probably do what you have in mind, because of the else clause.

      Your point re $min is well taken. Thanks for the explanation. I thought I needed it to deal with cases where $max came in the middle of a word, but I see now a proper regex does a better (and more generalized) job.

      re the plus six: what I was actually trying to do was to allow what would otherwise have been a very short ( < 7 chars ) lastline to be rendered together (printer's sense) with a standard-length penultimate line. ie, allow

      ...(59 chars) blah fit.

      to render as

      | ...blah fit. | #bars mark edge of frame

      rather than as
      | ...blah. | | fit. |

      but that got lost in my match_count mess.

      <G>and your first line offers more food for thought, but what I need now is actual chow...

      Afterthought: Should or can this node be renamed? Your answers make it clear that my (title) ref to split's behavior wasn't really the issue (and I would hate to have folk looking for info on split spending time OFF-topic).
      cheers.