diff --git a/lib/calcms/audio_recordings.pm b/lib/calcms/audio_recordings.pm index 0eb4666..a7b0195 100644 --- a/lib/calcms/audio_recordings.pm +++ b/lib/calcms/audio_recordings.pm @@ -23,11 +23,7 @@ sub get_columns($) { my $dbh = db::connect($config); my $cols = db::get_columns( $dbh, 'calcms_audio_recordings' ); - my $columns = {}; - for my $col (@$cols) { - $columns->{$col} = 1; - } - return $columns; + return { map { $_ => undef } @$cols }; } # get playout entries diff --git a/lib/calcms/calendar.pm b/lib/calcms/calendar.pm index 9a89b85..70be184 100644 --- a/lib/calcms/calendar.pm +++ b/lib/calcms/calendar.pm @@ -164,10 +164,7 @@ sub get($$) { exclude_locations => 1, } ); - my $used_day = {}; - for my $day (@$used_days) { - $used_day->{ $day->{start_date} } = 1; - } + my $used_day = { map { $_->{start_date} => 1 } @$used_days }; for my $year ( sort { $a <=> $b } keys %$years ) { my $months = $years->{$year}; diff --git a/lib/calcms/comments.pm b/lib/calcms/comments.pm index 0fc1aa7..3bcdeb0 100644 --- a/lib/calcms/comments.pm +++ b/lib/calcms/comments.pm @@ -390,12 +390,7 @@ sub get_events($$$$) { my $params = $request->{params}->{checked}->{comment}; #get event_ids from comments - my $event_ids = {}; - for my $comment (@$comments) { - my $event_id = $comment->{event_id}; - $event_ids->{$event_id} = 1; - } - + my $event_ids = { map { $_->{event_id} => 1 } @$comments }; my @keys = keys %{$event_ids}; #get events from comment's event ids return [] if ( scalar @keys ) == 0; diff --git a/lib/calcms/creole_wiki.pm b/lib/calcms/creole_wiki.pm index 8452645..1ab1406 100644 --- a/lib/calcms/creole_wiki.pm +++ b/lib/calcms/creole_wiki.pm @@ -191,10 +191,7 @@ sub extractMeta ($$) { if ( defined $comments ) { #build index for meta already defined - my $meta_keys = {}; - for my $pair (@$meta) { - $meta_keys->{ $pair->{name} . '=' . $pair->{value} } = 1; - } + my $meta_keys = { map { $_->{name}."=".$_->{value} => 1 } @$meta }; while ( $comments =~ /\~\~META\:(.+?)\=(.+?)\~\~/g ) { my $name = $1; diff --git a/lib/calcms/db.pm b/lib/calcms/db.pm index ed2c850..97dfb99 100644 --- a/lib/calcms/db.pm +++ b/lib/calcms/db.pm @@ -125,11 +125,7 @@ sub get_columns_hash($$) { my $table = shift; my $columns = db::get_columns( $dbh, $table ); - my $result = {}; - for my $column (@$columns) { - $result->{$column} = 1; - } - return $result; + return { map { $_ => 1 } @$columns }; } #returns last inserted id diff --git a/lib/calcms/event_history.pm b/lib/calcms/event_history.pm index 94b5524..7f9c836 100644 --- a/lib/calcms/event_history.pm +++ b/lib/calcms/event_history.pm @@ -16,11 +16,7 @@ sub get_columns ($){ my $dbh = db::connect($config); my $cols = db::get_columns( $dbh, 'calcms_event_history' ); - my $columns = {}; - for my $col (@$cols) { - $columns->{$col} = 1; - } - return $columns; + return { map { $_ => undef } @$cols }; } sub get ($$){ diff --git a/lib/calcms/password_requests.pm b/lib/calcms/password_requests.pm index 76bf2cc..376ec9d 100644 --- a/lib/calcms/password_requests.pm +++ b/lib/calcms/password_requests.pm @@ -23,11 +23,7 @@ sub get_columns ($) { my $dbh = db::connect($config); my $cols = db::get_columns( $dbh, 'calcms_password_requests' ); - my $columns = {}; - for my $col (@$cols) { - $columns->{$col} = 1; - } - return $columns; + return { map { $_ => undef } @$cols }; } sub get ($$) { diff --git a/lib/calcms/playout.pm b/lib/calcms/playout.pm index 40372bc..beef723 100644 --- a/lib/calcms/playout.pm +++ b/lib/calcms/playout.pm @@ -20,11 +20,7 @@ sub get_columns ($) { my $dbh = db::connect($config); my $cols = db::get_columns( $dbh, 'calcms_playout' ); - my $columns = {}; - for my $col (@$cols) { - $columns->{$col} = 1; - } - return $columns; + return { map { $_ => undef } @$cols }; } diff --git a/lib/calcms/project.pm b/lib/calcms/project.pm index 78dbdad..3e89d21 100644 --- a/lib/calcms/project.pm +++ b/lib/calcms/project.pm @@ -30,11 +30,7 @@ sub get_columns ($) { my $dbh = db::connect($config); my $cols = db::get_columns( $dbh, 'calcms_projects' ); - my $columns = {}; - for my $col (@$cols) { - $columns->{$col} = 1; - } - return $columns; + return { map { $_ => undef } @$cols }; } # get projects diff --git a/lib/calcms/series.pm b/lib/calcms/series.pm index 903e2ff..894ff38 100644 --- a/lib/calcms/series.pm +++ b/lib/calcms/series.pm @@ -34,11 +34,7 @@ sub get_columns ($) { my $dbh = db::connect($config); my $cols = db::get_columns( $dbh, 'calcms_series' ); - my $columns = {}; - for my $col (@$cols) { - $columns->{$col} = 1; - } - return $columns; + return { map { $_ => undef } @$cols }; } # get series content @@ -772,14 +768,14 @@ sub get_images ($$) { series_id => $options->{series_id} } ); - my $images = {}; - my $found = 0; - for my $event (@$events) { - my $image = $event->{image}; - $image =~ s/.*\///; - $images->{$image} = 1; - $found++; - } + my $images = { + map { + my $image = $_->{image}; + $image =~ s/.*\///; + { $image => 1 }; + } @$events + }; + my $found = scalar(keys %$images); return undef if $found == 0; @@ -948,10 +944,7 @@ sub set_event_ids ($$$$$) { return unless defined $event_ids; #make lookup table from events - my $event_id_hash = {}; - for my $event_id (@$event_ids) { - $event_id_hash->{$event_id} = 1; - } + my $event_id_hash = { map { $_ => 1 } @$event_ids }; #get series_entries from db #my $bind_names=join(',', (map { '?' } @$event_ids)); @@ -964,16 +957,8 @@ sub set_event_ids ($$$$$) { my $dbh = db::connect($config); my $results = db::get( $dbh, $query, $bind_values ); - my $found = {}; - #mark events found assigned to series - my $i = 1; - for my $event (@$results) { - - #print "found event $i: $event->{event_id}\n"; - $found->{ $event->{event_id} } = 1; - $i++; - } + my $found = { map { $_->{event_id} => 1 } @$results }; #insert events from list, not found in db for my $event_id (@$event_ids) { diff --git a/lib/calcms/series_dates.pm b/lib/calcms/series_dates.pm index c8d0871..0565c7f 100644 --- a/lib/calcms/series_dates.pm +++ b/lib/calcms/series_dates.pm @@ -26,11 +26,7 @@ sub get_columns ($) { my $dbh = db::connect($config); my $cols = db::get_columns( $dbh, 'calcms_series_dates' ); - my $columns = {}; - for my $col (@$cols) { - $columns->{$col} = 1; - } - return $columns; + return { map { $_ => undef } @$cols }; } # get all series_dates for studio_id and series_id within given time range @@ -261,12 +257,8 @@ sub addSeriesScheduleAttributes ($$) { my $config = shift; my $entries = shift; - my $scheduleIds = {}; - # get series schedule ids used at entries - for my $entry (@$entries) { - $scheduleIds->{ $entry->{series_schedule_id} } = 1; - } + my $scheduleIds = { map { $_->{series_schedule_id} => 1 } @$entries }; my @scheduleIds = keys %$scheduleIds; return $entries if scalar(@scheduleIds) == 0; diff --git a/lib/calcms/series_events.pm b/lib/calcms/series_events.pm index 28ccef6..1a21cf6 100644 --- a/lib/calcms/series_events.pm +++ b/lib/calcms/series_events.pm @@ -41,7 +41,7 @@ sub save_content($$) { my $config = shift; my $entry = shift; - return undef unless ( defined $entry->{id} ); + return undef unless defined $entry->{id}; for my $attr ( keys %$entry ) { next unless defined $entry->{$attr}; @@ -308,10 +308,7 @@ sub check_permission($$) { delete $options->{permission}; #convert check list to hash - my $check = {}; - for my $permission ( @{ $options->{check_for} } ) { - $check->{$permission} = 1; - } + my $check = { map { $_ => 1 } @{ $options->{check_for} } }; delete $options->{check_for}; # is project assigned to studio diff --git a/lib/calcms/series_schedule.pm b/lib/calcms/series_schedule.pm index cc4ebac..dbcbf8d 100644 --- a/lib/calcms/series_schedule.pm +++ b/lib/calcms/series_schedule.pm @@ -28,11 +28,8 @@ sub get_columns ($) { my $dbh = db::connect($config); my $cols = db::get_columns( $dbh, 'calcms_series_schedule' ); - my $columns = {}; - for my $col (@$cols) { - $columns->{$col} = 1; - } - return $columns; + return { map { $_ => undef } @$cols }; + } #map schedule id to id diff --git a/lib/calcms/studio_timeslot_dates.pm b/lib/calcms/studio_timeslot_dates.pm index 61be874..d407a02 100644 --- a/lib/calcms/studio_timeslot_dates.pm +++ b/lib/calcms/studio_timeslot_dates.pm @@ -22,11 +22,7 @@ sub get_columns ($){ my $dbh = db::connect($config); my $cols = db::get_columns( $dbh, 'calcms_studio_timeslot_dates' ); - my $columns = {}; - for my $col (@$cols) { - $columns->{$col} = 1; - } - return $columns; + return { map { $_ => undef } @$cols }; } # get all studio_timeslot_dates for studio_id within given time range diff --git a/lib/calcms/studio_timeslot_schedule.pm b/lib/calcms/studio_timeslot_schedule.pm index 521f4d9..3198132 100644 --- a/lib/calcms/studio_timeslot_schedule.pm +++ b/lib/calcms/studio_timeslot_schedule.pm @@ -20,11 +20,7 @@ sub get_columns($) { my $dbh = db::connect($config); my $cols = db::get_columns( $dbh, 'calcms_studio_timeslot_schedule' ); - my $columns = {}; - for my $col (@$cols) { - $columns->{$col} = 1; - } - return $columns; + return { map { $_ => undef } @$cols }; } #map schedule id to id diff --git a/lib/calcms/studios.pm b/lib/calcms/studios.pm index f9fbeca..77f05ac 100644 --- a/lib/calcms/studios.pm +++ b/lib/calcms/studios.pm @@ -17,11 +17,7 @@ sub get_columns($) { my $dbh = db::connect($config); my $cols = db::get_columns( $dbh, 'calcms_studios' ); - my $columns = {}; - for my $col (@$cols) { - $columns->{$col} = 1; - } - return $columns; + return { map { $_ => undef } @$cols }; } sub get($;$) { my $config = shift; diff --git a/lib/calcms/user_default_studios.pm b/lib/calcms/user_default_studios.pm index 4c96999..58d0090 100644 --- a/lib/calcms/user_default_studios.pm +++ b/lib/calcms/user_default_studios.pm @@ -16,13 +16,9 @@ sub debug; sub get_columns($) { my $config = shift; - my $dbh = db::connect($config); - my $cols = db::get_columns( $dbh, 'calcms_user_default_studios' ); - my $columns = {}; - for my $col (@$cols) { - $columns->{$col} = 1; - } - return $columns; + my $dbh = db::connect($config); + my $cols = db::get_columns( $dbh, 'calcms_user_default_studios' ); + return { map { $_ => undef } @$cols }; } sub get ($$) { diff --git a/lib/calcms/user_sessions.pm b/lib/calcms/user_sessions.pm index 6d1f52a..97566f3 100644 --- a/lib/calcms/user_sessions.pm +++ b/lib/calcms/user_sessions.pm @@ -28,11 +28,7 @@ sub get_columns($) { my $dbh = db::connect($config); my $cols = db::get_columns( $dbh, 'calcms_user_sessions' ); - my $columns = {}; - for my $col (@$cols) { - $columns->{$col} = 1; - } - return $columns; + return { map { $_ => undef } @$cols }; } #map schedule id to id diff --git a/lib/calcms/user_settings.pm b/lib/calcms/user_settings.pm index 4b9d62b..2a85de7 100644 --- a/lib/calcms/user_settings.pm +++ b/lib/calcms/user_settings.pm @@ -138,11 +138,7 @@ sub get_columns($) { my $dbh = db::connect($config); my $cols = db::get_columns( $dbh, 'calcms_user_settings' ); - my $columns = {}; - for my $col (@$cols) { - $columns->{$col} = 1; - } - return $columns; + return { map { $_ => undef } @$cols }; } sub get ($$) { diff --git a/lib/calcms/user_stats.pm b/lib/calcms/user_stats.pm index 1561215..54aad9e 100644 --- a/lib/calcms/user_stats.pm +++ b/lib/calcms/user_stats.pm @@ -15,11 +15,7 @@ sub get_columns($) { my $dbh = db::connect($config); my $cols = db::get_columns( $dbh, 'calcms_user_stats' ); - my $columns = {}; - for my $col (@$cols) { - $columns->{$col} = 1; - } - return $columns; + return { map { $_ => undef } @$cols }; } sub get ($$) { @@ -205,7 +201,7 @@ sub increase ($$$) { return undef unless defined $options->{user}; my $columns = get_columns($config); - return undef unless defined $columns->{$usecase}; + return undef unless exists $columns->{$usecase}; my $entries = get( $config, $options ); if ( scalar @$entries == 0 ) { diff --git a/lib/calcms/work_dates.pm b/lib/calcms/work_dates.pm index 7c80b10..c46ca2b 100644 --- a/lib/calcms/work_dates.pm +++ b/lib/calcms/work_dates.pm @@ -26,11 +26,7 @@ sub get_columns($) { my $dbh = db::connect($config); my $cols = db::get_columns( $dbh, 'calcms_work_dates' ); - my $columns = {}; - for my $col (@$cols) { - $columns->{$col} = 1; - } - return $columns; + return { map { $_ => undef } @$cols }; } # get all work_dates for studio_id and schedule_id within given time range diff --git a/lib/calcms/work_schedule.pm b/lib/calcms/work_schedule.pm index bc0c078..51039b9 100644 --- a/lib/calcms/work_schedule.pm +++ b/lib/calcms/work_schedule.pm @@ -27,11 +27,7 @@ sub get_columns($) { my $dbh = db::connect($config); my $cols = db::get_columns( $dbh, 'calcms_work_schedule' ); - my $columns = {}; - for my $col (@$cols) { - $columns->{$col} = 1; - } - return $columns; + return { map { $_ => undef } @$cols }; } #map schedule id to id diff --git a/website/agenda/planung/projects.cgi b/website/agenda/planung/projects.cgi index 2611840..2978435 100755 --- a/website/agenda/planung/projects.cgi +++ b/website/agenda/planung/projects.cgi @@ -237,11 +237,7 @@ sub show_projects { $project->{pid} = $project->{project_id}; # get assigned studios by id - my $assigned_studio_by_id = {}; - for my $studio (@$project_studio_assignements) { - $assigned_studio_by_id->{ $studio->{studio_id} } = 1; - } - + my $assigned_studio_by_id = { map { $_->{studio_id} => 1 } @$project_studio_assignements }; my $assigned_studios = []; my $unassigned_studios = []; for my $studio (@$studios) { diff --git a/website/agenda/planung/series.cgi b/website/agenda/planung/series.cgi index 5d33a1b..0a4d695 100755 --- a/website/agenda/planung/series.cgi +++ b/website/agenda/planung/series.cgi @@ -333,7 +333,7 @@ sub save_series { # fill series entry my $entry = {}; for my $param ( keys %$params ) { - if ( defined $columns->{$param} ) { + if ( exists $columns->{$param} ) { $entry->{$param} = $params->{$param} || ''; } }