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
    Good point - depending on the OP's needs I can see where this would be useful.

    One issue I have with the solutions which use push is that if a file doesn't contain a name (or contains a name not found in other files), then the outputted data is not going to be lined up correctly. When implemented with a hash, the script can be used on non-uniform data files, and it makes it easy to spot data files which don't have the same names as the others (i.e. missing data.)