#!/usr/bin/perl -w use strict; use warnings FATAL => 'all'; $| = 1; #my $day_duration = 9; # hours #my $night_duration = 8; # hours #my $night_duration = 8; # hours #my $day_duration = 24 - $night_duration; # hours #my $day_duration = 4; # hours #my $night_duration = 4; # hours #my $day_duration = shift || die; # hours #my $night_duration = shift || die; # hours my $day_duration = shift; # hours my $night_duration = shift; # hours die unless $day_duration =~ /^(\d+|\d+\.\d+)$/; die unless $night_duration =~ /^(\d+|\d+\.\d+)$/; my $total_duration = $day_duration + $night_duration; #my $load = 0.2; # kilowatts #my $load = 0.230; # kilowatts #my $load = 0.500; # kilowatts #my $load = 1.2; # kilowatts #my $load = shift || die; # kilowatts my $load = shift; # kilowatts die unless $load =~ /^(\d+|\d+\.\d+)$/; my $day_energy = $load * $day_duration; # kilowatts * hours my $night_energy = $load * $night_duration; # kilowatts * hours #my $day_tariff = (149.19 + 3.58 + 5.90) / 100; # EEK / kWh #my $night_tariff = (86.53 + 3.58 + 5.90) / 100; # EEK / kWh #my $day_tariff = (152.75 + 3.58 + 5.90) / 100; # EEK / kWh #my $night_tariff = (88.59 + 3.58 + 5.90) / 100; # EEK / kWh #my $day_tariff = (70.20 + 82.55 + 3.58 + 5.90) / 100; # EEK / kWh #my $night_tariff = (40.71 + 47.88 + 3.58 + 5.90) / 100; # EEK / kWh # >= 2009-01-01 #my $day_tariff = (77.84 + 83.39 + 7.16 + 5.90) / 100; # EEK / kWh #my $night_tariff = (45.15 + 48.37 + 7.16 + 5.90) / 100; # EEK / kWh # >= 2009-03-01 #my $day_tariff = (77.93 + 86.68 + 7.16 + 5.90) / 100; # EEK / kWh #my $night_tariff = (45.19 + 50.28 + 7.16 + 5.90) / 100; # EEK / kWh # == 2010-09-04 my $day_tariff = 1.89; # EEK / kWh my $night_tariff = 1.19; # EEK / kWh my $day_eek = $day_energy * $day_tariff; # = EEK my $night_eek = $night_energy * $night_tariff; # = EEK my $day_night_24h_eek = $day_eek + $night_eek; my $day_night_tariff_20d = 20 * $day_night_24h_eek; # = EEK my $night_tariff_10d = 10 * ($day_energy + $night_energy) * $night_tariff; # = EEK my $total_eek_month = $day_night_tariff_20d + $night_tariff_10d; my $total_eek_3_month = 3 * $total_eek_month; my $total_eek_6_month = 6 * $total_eek_month; my $total_eek_1_year = 12 * $total_eek_month; my @output = ( [ 'night duration', $night_duration, 'h', ], [ 'day duration', $day_duration, 'h', ], '', [ 'total duration', $total_duration, 'h', ], '', [ 'load', $load, 'kW', ], [ 'load', $load * 1000, 'W', ], '', '', [ 'day energy', $day_energy, 'kWh', ], [ 'night energy', $night_energy, 'kWh', ], '', [ 'day tariff', $day_tariff, 'EEK / kWh', ], [ 'night tariff', $night_tariff, 'EEK / kWh', ], '', [ 'day eek', $day_eek, 'EEK', ], [ 'night eek', $night_eek, 'EEK', ], '', [ 'day/night 1 day', $day_night_24h_eek, 'EEK', ], [ 'day/night tariff 20 days', $day_night_tariff_20d, 'EEK', ], '', [ 'night tariff 10 days', $night_tariff_10d, 'EEK', ], '', '', [ 'total 1 month', $total_eek_month, 'EEK', ], '', [ 'total 3 month', $total_eek_3_month, 'EEK', ], [ 'total 6 month', $total_eek_6_month, 'EEK', ], [ 'total 1 year', $total_eek_1_year, 'EEK', ], ); print "\n\n"; foreach my $item (@output) { if (ref $item eq '' && $item eq '') { print "\n"; next; } printf "%28s %18s %s\n", ucfirst $item->[0], $item->[1], $item->[2]; } print "\n\n";