1..2 2017-09-04 = 1 not ok 1 - 2017-09-04 tally correct # Failed test '2017-09-04 tally correct' # at C:\Users\li\test9.pl line 67. # got: '1' # expected: '3' not ok 2 - 2017-09-30 tally correct # Failed test '2017-09-30 tally correct' # at C:\Users\li\test9.pl line 68. # got: undef # expected: '2' # Looks like you failed 2 tests of 2. #### use Data::Dumper; open (OUT1, ">alldata.txt") or die; %mycorpus = getCorpus('C:\Users\li\test11'); my $href = \%mycorpus; # reference to the hash %mycorpus print OUT1 Dumper $href; # note the order will differ from that above print OUT1 "\n"; open (OUT2, ">editeddata.txt") or die; open( FILE, "alldata.txt" ) || die "couldn't open\n"; $/ = undef; while () { while (/(?<=##)(.*)(?=##)/g) { print OUT2 "$1\n"; } #### open(FILE, 'C:\Users\li\test11\164949.txt'); while () { if ( /(?<=##)(.*)(?=##)/g ) { print "$1\n"; } }