in reply to Re: Take Data out from unknown number of files
in thread Parse values from multiple files into one

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^3: Take Data out from unknown number of files
by jwkrahn (Abbot) on Nov 10, 2008 at 09:42 UTC

    UNTESTED, but perhaps something like this:

    use List::Util 'sum'; my @su_files = glob "SU*"; my @mu_files = glob "MU*"; @ARGV = ( @su_files, @mu_files ); my %data; while ( <> ) { my ( $key, $number ) = split /\t/; push @{ $data{ $key }{ lc substr $ARGV, 0, 2 } }, $number; } print join( "\t", 'Header', @su_files, 'average', @mu_files, 'average' + ), "\n"; for my $key ( sort keys %data ) { my ( $su, $mu ) = @{ $data{ $key } }{ qw/ su mu / }; print join( "\t", $key, @$su, sum( @$su ) / @$su, @$mu, sum( @$mu +) / @$mu ), "\n"; }
      Thanks..Yeah this is what I want..But there are other things I need to do before..Can I take ur help if needed?!! Thanks a bunch!
    A reply falls below the community's threshold of quality. You may see it by logging in.