Jim Gibson <jimsgib...@gmail.com> writes:

> You might try splitting the line on whitespace, extracting the first two and
> last two elements, then joining the remainder back with a space. You can
> then test the length of the middle string for excessive length and print or
> trim accordingly. This will concatenate any extra spaces in the middle
> string.
>
> This only works if the first two and last two fields contain no spaces.

Thanks.. pretty much what I thought up too.  But it turns out to be a
little more complicated.  There are other pieces in a few lines such
as a date string like `date' puts out by default, that has spaces.
And a few others

I'm thinking of splitting on something like '  +' (<spc><spc>+) since
no regular output will have 2 spc or more between connected
words.... I mean words that belong in a group.

A quick test with:

  while(<>){
     my @linar = split(/  +/,$_);
     print "<" . @linar . ">\n";
  }

Shows all lines split into 4 elements... which is what I want... then
I can test for a long element and fold it... maybe on commas since the
options are separated by commas.

Do you have any idea if that would cause significant cpu usage.  I
mean testing every field for length.   There would be 4 per line and
some 100+ lines.  So, 400+ tests.


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to