It's not clear to me what you mean by "generalise", but this simplifies it a little, and appears to produce similar output for the test case:
#! perl -slw
use strict;
use Data::Dump qw[ pp ];
my %in;
m[(\d\d):\d\d (.+)$] and push @{ $in{ $1 } }, $2 while <DATA>;
for my $hr ( sort{ $a <=> $b } keys %in ) {
my $n = $#{ $in{ $hr } };
my $step = 60 / $n;
my $min = 0;
for my $flight ( @{ $in{ $hr } } ) {
printf( "%02d:%02d %s\n", $hr, int( $min ), $flight );
$min += $step;
$min = 59 if $min > 59;
}
}
__DATA__
11:10 A1
11:30 E4
11:30 Z4
11:50 H5
12:02 H6
12:25 B2
12:25 A8
12:30 F3
12:30 E7
12:50 E15
12:55 E16
Produces:
C:\test>725886.pl
11:00 A1
11:20 E4
11:40 Z4
11:59 H5
12:00 H6
12:10 B2
12:20 A8
12:30 F3
12:40 E7
12:50 E15
12:59 E16
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.