in reply to Re^3: Counting iterations of 1 and 0
in thread Counting iterations of 1 and 0

Well, now at least I am getting a long list of 1's.

Here is what I am using.

use warnings; use strict; use autodie; open IN, "<D:\\baseline_pattern.txt"; binmode IN; my @content = <IN>; close IN; foreach my $num (qw/0 1/) { my @count = ("@content" =~ /$num+/sg); open my $fh, ">iterations$num.txt"; print "$_\n" for @count; close $fh; }

There are files "D:\iterations_1.txt" and "D:\iterations_0.txt" that I created.

However there was nothing written to these files.

Should there be a sprintf?

Replies are listed 'Best First'.
Re^5: Counting iterations of 1 and 0
by Bloodnok (Vicar) on Feb 04, 2014 at 17:52 UTC
    Nope, print is, or should be doing the job - looks like there might've been 2 mistakes -, try print $fh "$_\n" for @count;
    A user level that continues to overstate my experience :-))