Guruguhan N wrote:
>
>           I have a data set ( only a portion) as follows:
>    No.     x1         x2         x3        y1          y2        y3          y4
>    1   0.200000   0.200000   0.200000   0.765685    75881.9    29289.3   -46592.6
>    2   0.200345   0.200000   0.200345   0.766661    75766.0    29268.4   -46497.6
>    3   0.200000   0.200345   0.200000   0.766030    75867.1    29259.8   -46607.4
>    4   0.359575   0.253987   0.359575   1.271019    43898.7    19675.6   -24223.1
>    5   0.359921   0.253987   0.359921   1.271995    43861.3    19666.1   -24195.2
>
> This data set has to be filtered using the following conditions ( example only. in 
> reality this can be anything):
>
> 0.2 < x1 < 0.3
> y1 > 0.8
> 15000 < y3 < 30000
>
> I have to filter the data set satisfying all the conditions.

Hi.

Unfortunately none of your data satisfy the criteria! But taking just the
limits on x1 the program below should help. It works by grabbing the column
headers and using them as the keys of a hash for the following data. That allows
you to write the conditions in meaningful terms.

I hope it helps,

Rob



use strict;
use warnings;

my @keys = split ' ', <DATA>;

my %data;

while (<DATA>) {

  @[EMAIL PROTECTED] = split ' ';

  next unless
    0.2 < $data{x1} && $data{x1} < 0.3; # &&
#    $data{y1} > 0.8;
#    15000 < $data{y3} && $data{y3} < 30000;

  print "@[EMAIL PROTECTED]";

}

__DATA__
   No.     x1         x2         x3        y1          y2        y3          y4
   1   0.200000   0.200000   0.200000   0.765685    75881.9    29289.3   -46592.6
   2   0.200345   0.200000   0.200345   0.766661    75766.0    29268.4   -46497.6
   3   0.200000   0.200345   0.200000   0.766030    75867.1    29259.8   -46607.4
   4   0.359575   0.253987   0.359575   1.271019    43898.7    19675.6   -24223.1
   5   0.359921   0.253987   0.359921   1.271995    43861.3    19666.1   -24195.2

**OUTPUT

2 0.200345 0.200000 0.200345 0.766661 75766.0 29268.4 -46497.6



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to