On 7/4/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
File1:example.txt ProbeNames Exp1 Exp2 Exp3 Exp4 Exp5 244901_at 24.3 46.4 37.4 19.5 59.6 244902_at 36.6 92.4 49.5 42.4 29.6 244903_at 46.4 19.4 - 18.2 19.8 244904_at 56.2 29.4 78.4 37.8 -
i want to find the average value for each Probe i.e each horizontal line.For ex:Avg value for 244901_at is so and so,avg value for 244902_at is so and so..
It looks as if you're off to a good start; maybe you should use a pattern match to describe your data? # untested code my $datum = qr{[\d\-\.]+}; # or something better for your data my $ident = qr{\w+}; my $pattern = qr{ ^($ident) # $1 is identifier at start of line \s+ # whitespace ( # $2 is list of data items (?:$datum\s+)* # items before last item $datum # last item ) }x; # later, when you're ready to read from your data file while ($line = <FILE>) { next unless $line =~ /\S/; # skip blank lines if ($line =~ /$pattern/) { my($ident, $data) = ($1, $2); next if $ident eq 'ProbeNames'; # skip headings my @data = split /\s+/, $data; my $average = &my_average(@data); # or whatever print "Probe $ident reports average $average\n"; # on your own from here } else { warn "Unusable data found on line $. of file, continuing...\n"; } } Hope this helps! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/