in reply to creating smaller files from one large one

#!/usr/bin/perl use warnings; use strict; # process headers, create filehandles my @fhs; for my $header ( split ' ', <DATA> ) { my $file = "$header.dat"; open my $FH, '>', $file or die "Cannot open '$file' $!"; push @fhs, $FH; } while ( <DATA> ) { my @fields = /\S+\s+\S+/g; @fields == @fhs or die "Error: incorrect number of fields in recor +d $.\n"; for my $fh ( @fhs ) { print $fh shift( @fields ), "\n"; } } __DATA__ item1 item2 item3 0 0 1 S 0 0 0 0 2 K 0 0 0 0 23 T 1 M 12 T 24 N 2 L 45 0 36 V 14 I 46 0 38 W 16 R 51 S 39 A 17 L 52 A 42 N 20 E 53 0 43 L 21 G