Please understand that I am new to the Monastery. That said, why wouldn't something like this work if the data always has spaces between the numbers?

#!/usr/bin/perl use strict; while( <DATA> ) { my @numbers = split; my $half = int(@numbers/2); my @first = splice(@numbers,0,$half); print "@first\n"; print " @numbers\n"; } __DATA__ 105 106 107 108 109 110 111 112 113 1115 1116 1117 1118 1119 1120 1121 1122 1123 12345 12346 12347 12348 12349 12350 12351 12353

The first snippet just cuts the line in half, but it could easily be adapted to print out lines of X number of values (with continuation rows indented.)

#!/usr/bin/perl use strict; my $maxitems = 3; while( <DATA> ) { my @numbers = split; my $indent = ''; while ( @numbers > 0) { my @rowdata = splice(@numbers,0,$maxitems); print "${indent}@rowdata\n"; $indent = ' '; } } __DATA__ 105 106 107 108 109 110 111 112 113 116 1115 1116 1117 1118 1119 1120 1121 1122 1123 1125 12345 12346 12347 12348 12349 12350 12351 12353 12355

UPDATE: I understand that this doesn't answer the question posed (which is interesting in itself) but I have to wonder if that is the right approach to the task at hand to begin with.


In reply to Re: Why doesn't this regex work? by boftx
in thread Why doesn't this regex work? (Solved!) by BrowserUk

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.