Loading ...
Sorry, an error occurred while loading the content.

Yesterday was (Help!)

Expand Messages
  • Charles K. Clarkson
    ... I understand what the code does. I m not sure what your trying to do with the log files. If the date doesn t match yesterday, what should happen? Here s a
    Message 1 of 1 , Apr 27, 2002
    • 0 Attachment
      "Ken Arck" <ph@...> wrote:


      : The logfile I'm wanting to parse has multiple lines, each in the format below:
      :
      : 04/25/02 , 10:22:22 , 50.0, F , 99.99, MPH, South ,180.0 , 0
      :
      : If you need, I can explain what I am trying to do (if you can't figure it
      : out from the code <g>).

      I understand what the code does. I'm not sure what your trying
      to do with the log files. If the date doesn't match yesterday, what
      should happen?

      Here's a little short hand:

      open LOG, $log_file_path or die "Cannot open $log_file_path: $!";

      while ( <LOG> ) {
      my %line;
      @line{ qw| date time temp wind_speed
      wind_dir_name wind_dir_number | } =
      (split /\s*,\s*/)[0, 1, 2, 4, 6, 7];

      next unless $current{date} eq $yesterday_formatted;

      #
      # This line ($_) is from yesterday
      #

      # It is separated in the hash %line
      }

      (split /\s*,\s*/)[0, 1, 2, 4, 6, 7];

      Does everything this did in 1 step:

      @stuff = split(/,/, $line); #remove commas and build array

      foreach (@stuff) {
      s/ //gi;
      }

      It returns just the fields you need:

      ( $current_date, $current_time, $current_temp, $current_wind_speed,
      $current_wind_dir_name, $current_wind_dir_num ) =
      (split /\s*,\s*/)[0, 1, 2, 4, 6, 7];

      The above is a drop-in replacement for your code.

      $yesterday_formatted is returned from the process needed
      to obtain a scalar of the form 'mm/dd/yy' for yesterday's date.


      Does this make any sense? Is it what you're looking for?

      Charles
    Your message has been successfully submitted and would be delivered to recipients shortly.