Given that you're going to want to look at the date anyway, you might as well pick your data apart into columns. If you're sure that you'll have no whitespace in your 'moredata', you could just do a split without a limit, but to play it safe I'll just split the first few columns (untested):
# Each eat of splitLines will hold an array ref my @splitLines; foreach my $line (@calls) { my @bits = split(/\s+/, $line, 4); # Discard the first column shift @bits; # We want to sort by date, so we'll parse # the date column and prefix with a sortable value my ($mday, $month, $year) = split(m!/!, $bits[1]); $month -= 1; # mktime wants month from 0 $year += 100; # mktime wants year from 1900 my $when = POSIX::mktime(0, 0, 0, $mday, $month, $year); unshift @bits, $when; push @splitLines, [ @bits ]; } # Sort by first elt @splitLines = sort { $a->[0] <=> $b->[0] } @splitLines; # And puts the lines back together again (discarding # the leading 'when'. @calls = map { shift @$_; join(' ', @$_) } @splitLines;
This seems over-long, but unless you write a more complex sort comparator (and hide the date parsing and processing etc in there) I'm not sure it can get much shorter. I don't like debugging complex sort comparators, so there you go.

In reply to Re: manipulating array by jbert
in thread manipulating array by gavintokyo

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.