use strict; use warnings; my $string=""; my %charmap = ( 0 => "a", 1 => "~" ); for (1..50000000) { $string .= $charmap{int(rand(2))}; } open (my $testfile,">","testfile.txt") or die $!; print $testfile $string; my @arr = split "~",$string; for (@arr) { print "$_\n"; }