#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11112358 use warnings; my @answers; /(\S+).*?Duration: (.*)/ and push @answers, "$1 $2\n" while <DATA>; print "Series Duration\n", sort @answers; __DATA__ Launching series_eleven (started Sat Jan 11 7:31:47 PST 2020) SERIES RESULT (series_eleven) : Pass: 2/0/0 series_eleven (finished Sat Jan 11 7:31:58 PST 2020) series_eleven Run Duration: 0d 00:00:11 Launching series_twenty (started Sat Jan 11 7:31:47 PST 2020) SERIES RESULT (series_twenty) : Pass: 2/0/0 series_twenty (finished Sat Jan 11 7:31:58 PST 2020) series_twenty Run Duration: 0d 00:00:20 Launching series_minute (started Sat Jan 11 7:31:47 PST 2020) SERIES RESULT (series_minute) : Pass: 2/0/0 series_minute (finished Sat Jan 11 7:31:58 PST 2020) series_minute Run Duration: 0d 00:01:00 Launching series_hour (started Sat Jan 11 7:31:47 PST 2020) SERIES RESULT (series_hour) : Pass: 2/0/0 series_hour (finished Sat Jan 11 7:31:58 PST 2020) series_hour Run Duration: 0d 01:00:00 Launching series_day (started Sat Jan 11 7:31:47 PST 2020) SERIES RESULT (series_day) : Pass: 2/0/0 series_day (finished Sat Jan 11 7:31:58 PST 2020) series_day Run Duration: 1d 00:00:00 Launching series_week (started Sat Jan 11 7:31:47 PST 2020) SERIES RESULT (series_week) : Pass: 2/0/0 series_week (finished Sat Jan 11 7:31:58 PST 2020) series_week Run Duration: 7d 00:00:00

Outputs:

Series Duration series_day 1d 00:00:00 series_eleven 0d 00:00:11 series_hour 0d 01:00:00 series_minute 0d 00:01:00 series_twenty 0d 00:00:20 series_week 7d 00:00:00

Guessing on alignment since you didn't put expected output in code tags :(


In reply to Re: i am trying to parse set of data from a file, sorting that data and writing to a new file by tybalt89
in thread i am trying to parse set of data from a file, sorting that data and writing to a new file by Anonymous Monk

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.