On 6/28/07, sum_duud <[EMAIL PROTECTED]> wrote:
in essence I would like the perl script to output all the fourth column "0" values to a file called phase_0.csv and all the "1" values to phase_1.csv etc.
snip
use an array of file handles (warning, untested): use strict; use warnings; open my $in, '<', "phase.csv" or die "Could not open phase.csv: $!\n"; <$in>; #discard first line my @file = map { open my $fh, '>', "phase_$_.csv" or die "could not open phase_$_.csv: $!"; $fh } 0 .. 20; while (<$in>) { chomp; my ($x, $y, $z, $phase) =split /\s*,\s*/; my $file = $file[$phase]; print $file "$x, $y, $z, $phase\n"; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/