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

Re: [PBML] filter data

Expand Messages
  • Charles K. Clarkson
    You are writing this solution from the top down. You do not have to write it in that order. Write the core algorithm first, then add the UI and I/O after that
    Message 1 of 5 , Aug 18, 2012
    • 0 Attachment
      You are writing this solution from the top down. You do not have to
      write it in that order. Write the core algorithm first, then add the UI
      and I/O after that is done.

      Eliminating the file conversion and the user interface stuff allows you
      to write and test the record comparison algorithm. Once that you know
      works, you can move on to make it look pretty for the user.

      use strict;
      use warnings;

      # Pull this info from file 1.
      my %is_valid = (
      1 => 1,
      2 => 1,
      3 => 1,
      );


      # Test data.
      # Replace this with a while loop over file 2 or a tied array.
      my @records = (
      '1 1 0 2 -9',
      '3 8 0 2 2',
      '2 6 0 1 6',
      '1 3 0 2 -9',
      '1 4 0 2 2',
      '2 2 0 1 6',
      );

      # Replace this with a while loop over file 2 or a tied array.
      while ( my $record = shift @records ) {

      my @fields = split ' ', $record;

      if ( $is_valid{ $fields[1] } ) {
      print "$record\n";
      }
      }

      __END__



      Charles Clarkson
      --
      I'm not really a smart person. I just play one on the Internet.
      +1 (254) 434-2733
    • Markus Tim
      Thank you for help and suggestion! [Non-text portions of this message have been removed]
      Message 2 of 5 , Aug 22, 2012
      • 0 Attachment
        Thank you for help and suggestion!

        [Non-text portions of this message have been removed]
      Your message has been successfully submitted and would be delivered to recipients shortly.