in reply to Is this possible
The main problem with the first two solutions presented is that they rely on the glob sort order so that 'RESULTS_FILE2' will be between 'RESULTS_FILE19' and 'RESULTS_FILE20', etc.
This will glob the files in the correct order:
#!/usr/bin/perl use warnings; use strict; @ARGV = map glob( 'RESULTS_FILE' . ( '[0-9]' x $_ ) ), 1 .. 4; my @headers = ( 'NAME', @ARGV ); my %data; while ( <> ) { my ( $name, $value ) = split; push @{ $data{ $name } }, $value; } print join( "\t", @headers ), "\n"; for my $name ( keys %data ) { print join( "\t", $name, @{ $data{ $name } } ), "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Is this possible
by pc88mxer (Vicar) on Mar 24, 2008 at 16:29 UTC |