Hi, I have to code a script to calc time elapsed in days as to calc the rent to be charged. The person would write an object number and date in a text file like
db.txt OBJECT_NUM, DATE_GIVEN 2525,25.11.2008 2526,01.01.2009 2527,26.11.2009 Now when he enter "OBJECT_NUM" I have to tell him the numbers of days elapsed since "DATE_GIVEN" and the rent he should charge which increases every 15 days like first 15 days = 2 next 15 days = 3 next 15 days = 5 next 15 days = 8 next 15 days = 10 now its always 10 So if the OBJECT is returned in say 40 days the rent charged is 10 (2 + 3 + 5) Being a beginner, I thought of hard coding the values in the code. if ( $days_elapsed <= 15 ) { $total_cost = 2; } elsif ( $days_elapsed <= 30 ) { $total_cost = 5; } elsif ( $days_elapsed <= 45 ) { $total_cost = 10; } elsif ( $days_elapsed <= 60 ) { $total_cost = 18; } elsif ( $days_elapsed <= 75 ) { $total_cost = 28; } elsif ( $days_elapsed <= 90 ) { $total_cost = 38; } else { print "More than 90 days! SPECIAL RATE\n"; exit; } HOW CAN I COUNT ELAPSED DAYS ? I tried in localtime() days value like my @array_date = localtime(); my $current_dayofyear = @array_date[7]; But this would break on New year as "$current_dayofyear" would be reset. SO HOW CAN I COUNT ELAPSED DAYS IF THE DATE FORMAT IS 01.01.2009?