From f0e446302ba371a2fd371a7f15168d3c125cbf3f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Thu, 17 Dec 2020 22:50:59 +0100 Subject: [PATCH] S:C:H:ReportGenerator: Spalteninformationen einzeln zuweisen. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Hintergrund: Das "fat-comma (=>)" interpretiert seine rechte Seite im Listenkontext, was dazu führen kann, dass der Hash, der aufgebaut werden soll, durcheinander gerät, wenn z.B. $def->{sub} eine Liste zurückliefert oder gar nichts ($def->{sub} = sub { return }). Interessant im Zusammenhang: https://stackoverflow.com/questions/3435122/whats-the-difference-between-return-and-return-undef-in-perl --- SL/Controller/Helper/ReportGenerator.pm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/SL/Controller/Helper/ReportGenerator.pm b/SL/Controller/Helper/ReportGenerator.pm index 41f0c6c36..513eda85b 100644 --- a/SL/Controller/Helper/ReportGenerator.pm +++ b/SL/Controller/Helper/ReportGenerator.pm @@ -128,13 +128,13 @@ sub report_generator_list_objects { for my $obj (@{ $params{objects} || [] }) { my %data = map { my $def = $column_defs->{$_}; - $_ => { - raw_data => $def->{raw_data} ? $def->{raw_data}->($obj) : '', - data => $def->{sub} ? $def->{sub}->($obj) - : $obj->can($_) ? $obj->$_ - : $obj->{$_}, - link => $def->{obj_link} ? $def->{obj_link}->($obj) : '', - }, + my $tmp; + $tmp->{raw_data} = $def->{raw_data} ? $def->{raw_data}->($obj) : ''; + $tmp->{data} = $def->{sub} ? $def->{sub}->($obj) + : $obj->can($_) ? $obj->$_ + : $obj->{$_}; + $tmp->{link} = $def->{obj_link} ? $def->{obj_link}->($obj) : ''; + $_ => $tmp; } @columns; $params{data_callback}->(\%data) if $params{data_callback}; -- 2.20.1