From: Ian Campbell Subject: Re: [OSSTEST] ms-planner: add a flight summary html report Date: Wed, 30 Apr 2014 17:29:45 +0100 Message-ID: <1398875385.5166.4.camel@kazak.uk.xensource.com> References: <1398677082-30965-1-git-send-email-ian.campbell@citrix.com> <21345.6748.9086.717380@mariner.uk.xensource.com> <1398873507.29888.19.camel@kazak.uk.xensource.com> <21345.8940.179394.862131@mariner.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <21345.8940.179394.862131@mariner.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Jackson Cc: xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On Wed, 2014-04-30 at 17:21 +0100, Ian Jackson wrote: > Ian Campbell writes ("Re: [OSSTEST] ms-planner: add a flight summary html report"): > > On Wed, 2014-04-30 at 16:44 +0100, Ian Jackson wrote: > > > This is rather a layering violation. Info is for the consumption of > > > humans. Perhaps the plan should have an explicit "flight.job" field. > > > > I was a bit more scared of touching the actual planner daemon... But ok. > > I think you can safely add new fields to the events, although the > existing planner daemon probably won't propagate them. "probably", fantastic ;-) > > > > + foreach my $job (sort { $inf->{Jobs}{$a}->{Start}->{Time} cmp $\ > > > inf->{Jobs}{$b}->{Start}->{Time} } keys %{ $inf->{Jobs} }) { > > > > > > You repeat the $inf->{Jobs}{$x}->{Start}->{Time} expression. Make it > > > an anonymous subref or something and this will become much clearer. > > > > You mean like: > > my $ta = sub { return $inf->{Jobs}{$a}->.... } > > my $tb = sub { return $inf->{Jobs}{$b}->.... } > > foreach ... (sort { $ta() cmp $tb() } keys ... ) { > > > > Or my $to = sub($) { my $it=shift; return $info-{Jobs}{$it}... } and > > $to($a) ? > > The latter. (Or a http://en.wikipedia.org/wiki/Schwartzian_transform > but that seems overkill.) Clever. But yes perhaps overkill... > Hrm, it turns out that some time in the last decade it became possible > to write local lexical subroutines that aren't coderefs. So try > sub sortkey { ... } > just before the sort. foreach my $foo(sub sortkey{} sort (keys %hash)) {} ? I don't think that can be what you meant. > > > How about > > > foreach my $se (qw(Start End)) { > > > ? > > > > OK. I never would have come up with that myself. > > Learn Common Lisp :-). Now I have two problems. ;-) Ian.