in reply to Re: parsing lists
in thread parsing lists

put the open inside the if block and the close outside the while block.

Caution: Contents may have been coded under pressure.

Replies are listed 'Best First'.
Re^3: parsing lists
by tphyahoo (Vicar) on Mar 04, 2005 at 09:31 UTC
    Yep. Ok this is tested and works.
    use warnings; use strict; my $count = 0; my $filename = "file0.csv"; open (DISTLISTS, " < rdy.csv") || die "Unable host file for splitting: + $!."; while (<DISTLISTS>) { chomp $_; if ( ($. - 1) % 200 == 0) { # modular arithmetic $count ++; my $filename = "file$count.csv"; open (OUTPUT1, " >$filename") } print OUTPUT1 "$_\n"; if ($. % 200 == 0) { # modular arithmetic close OUTPUT1; } }