#!/usr/bin/perl use warnings; $file =... open (TEMP, $file) or die("Error: cannot open $file\n"); $outfile =... open (OUTPUT,">$outfile"); select(OUTPUT); # explicitly select the new file for output #declare variables $counter_A=0; $counter_B=0; #counter for time of the day $counter_C=2; #counter for day of the week,date starts on tuesday @interval = (1..35040); #15 mins interval over a year 365 days $nline = "\n"; $scomma = ", "; $i = 0; while ($line = ) { @column = split (/,/,$line); @speed = split (/_/,$column[5]); foreach $timeint (@interval) { if ($counter_A==4) { $counter_A = 0; $counter_B++; if ($counter_B==24) {$counter_B = 0; $counter_C++; $i = 0; if (($counter_C>=6) && ($counter_C<8)) { $i = 96; } if ($counter_C==8) { $counter_C = 1; } } } print OUTPUT trim($column[0]).$scomma.trim($column[1]).$scomma.$speed[$i].$nline $counter_A++; $i++; } }