note
jbrugger
Just to explain what [chargrill] does here :<br>
<c>
# Create a lookuptable to store found items
my %hash = ();
# Iterate over the data-array (thats what grep does here), and add the item to newdata, and set the found item in the lookup table. When the new item is in the lookup table, don't add it again.
my @newdata = grep { ! $hash{ $_->{operation} . $_->{machine} }++ } @$data;
# more readable than grep (to my opinion,probably not to all others :) ), but basically the same:
my %hash = ();
my @newdata;
foreach my $item (@{$data}) {
if (! $hash{ $item->{operation} . $item->{machine} } ) {
$hash{ $item->{operation} . $item->{machine} } = 1 ;
push @newdata, $item;
}
}
</c>
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-417993">
<small>"We all agree on the necessity of compromise. We just can't agree on when it's necessary to compromise." - Larry Wall.</small>
</div></div>
574664
574667