Share-withs2

Output:

Day of week: MTWRFSS res1 xxxxxxx   los 7 res2 x         los 1 res3 xxx       los 3 res4  xx       los 2 res5    x      los 1 res6     xx    los 2 Actual occupancy:   2221110 res1 rcnt: 0.4375 res2 rcnt: 0.0625 res3 rcnt: 0.1875 res4 rcnt: 0.125 res5 rcnt: 0.0625 res6 rcnt: 0.125

Source code:

use strict; my @los = ( 7,1,3,2,1,2 ); my $total_room_nights; foreach (@los) { $total_room_nights += $_; } my $rcnt_total; my $res_num = 1; foreach (@los) { my $rcnt = $_ / $total_room_nights; $rcnt_total += $rcnt; print "res$res_num rcnt: $rcnt\n"; $res_num++; } print "\n\nTotal rcnt: $rcnt_total\n";