I have a data file (ex. Below) which starts
with the year, month and day and midway it changes to day, month and year. 
I have used the code snippet below to rewrite
the data, but it does not work
 my $dateST = qr{\d{4} \d{2} \d{2}};
my $dateEND = qr{\d{2} \d{2} \d{4}};
my $line;


  while
(<$infd>)
  {
    if($line =~ /^$ dateST /)
     {
              my ($year,$month,$day,$hour,$min,$sec,@rain)
= split;
      $_ = sprintf "%5.1f", $_ foreach
@rain;
  
      #
print $outfd " $year $month $day $hour $min $sec\t", join("
", @rain), "\n";
               print " $year $month $day $hour $min
$sec\t", join(" ", @rain), "\n";
     }
            elsif($line
=~ /^$ dateEND /)
     {
              my ($month,$day,$year,$hour,$min,$sec,@rain)
= split;
      $_ = sprintf "%5.1f", $_ foreach @rain;
  
      #
print $outfd " $year $month $day $hour $min $sec\t", join("
", @rain), "\n";
       print " $year $month $day $hour $min $sec\t", join("
", @rain), "\n";
     }
  }
Help will be appreciated.
Zilore

2012-07-04T15:00:00      29.44    30.70    32.14    0.85      100.00  25.52    
25.81    26.11    0.16      100.00  853.87  853.92            853.94  0.00      
100.00
04/07/2012 15.10.00       28.33    29.41    31.47    0.99      100.00  25.80    
26.01    26.27    0.14      100.00  853.88  853.91            853.95  0.00      
100.00


Note I first remove the dashes and slashes in
the date.
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to