2009-12-22,174865.6853,171 2009-12-23,158423.1442,155 2009-12-24,146650.9855,143 2009-12-25,127228.4832,124 2009-12-26,179032.6644,175 2009-12-27,179770.0221,176 2009-12-28,153049.9829,149 2009-12-29,159508.811,155 2009-12-30,75322.9348,143 2009-12-31,184494.3142,124 2010-01-01,88085.89262,87 2010-01-02,157525.6179,204 2010-01-03,213673.8187,214 2010-01-04,190080.1713,198 2010-01-05,139624.0644,155 2010-01-06,159684.3982,180 2010-01-07,159508.811,91 2010-01-08,75322.9348,130 2010-01-09,174867.4572,207 2010-01-10,206403.5704,86 2010-01-11,121876.6863,154 2010-01-12,89091.60969,209 2010-01-13,159684.3982,180 2009-01-14,153049.9829,149 #### #!/usr/bin/perl use strict; use warnings; # source file directory. my $srcdir = "../source"; # source file name. my $srcfile = $srcdir."/vol.dat"; # Open source file in READ mode. open (READ, "< $srcfile") || die "Can't find the DAT file\n"; ################## Start date time i.e. the first day of the last 30 days, is calculated by this code. my $epochToday1 = time; $epochToday1 = $epochToday1 - 2592000; my ($year1, $month1, $day1) = (localtime($epochToday1))[5,4,3]; $month1++; $year1+=1900; my $startdate = $year1."-".$month1."-".$day1; ######################## ################## End date time i.e. the current day, is calculated by this code. my $epochToday2 = time; my ($year2, $month2, $day2) = (localtime($epochToday2))[5,4,3]; $month2++; $year2+=1900; my $enddate = $year2."-".$month2."-".$day2; ######################## # Destination Directory. my $desdir = "../target"; #destination File name. my $desfile = $desdir."/total_volume_last30days.csv"; #Open target file in Write mode. open (WRITE, "> $desfile") || die "Can't find the CSV file.\n"; # Print the headers for the Report in CSV. my @headers = ("Date",",","Total_Volume"); print WRITE @headers,"\n"; my $printout; #declaration of variable which prints in the Target file. while () { my $start = $startdate; my $end = $enddate; if ( /^$start/ .. /^$end/ ) #range to be checked and written to Target file. { chomp; my (@items) = split (/,/,$_); my $tot = $items[1]+ $items[2]; #sum of incoming an outgoing bytes. $printout .= "$items[0],$tot \n"; #variable which stores the Data to be written in target file. } } print WRITE $printout; #write $printout values to Target file. close READ || die "Couldn't close the DAT file"; #close input file. close WRITE || die "Couldn't close the CSV file"; #close target file. exit 0; #### Use of uninitialized value $printout in print at total_volume_last30.pl line 67, line 122.