#!/usr/bin/perl -w use strict; my %fh; my @files = qw(Q ALPHA Z1 Z2 I TIM REF LOGREF S1G S2G DS1 DS2); for (@files) { open my $fh, ">$_.txt"; $fh{$_} = $fh; } while (<>) { chomp; next if /^#/ || length == 0; my @data = split / +/; my $i = 0; for (@files) { my $FH = $fh{$files[$i]}; print $FH $data[$i]."\n"; $i++; } }