#!/usr/bin/perl -w use strict; my $str="BATCATDATEFEAT"; my $A=0; my $T=0; while ($str =~ /A/ig) { $A++;# Line 4 print "\n A=$A ends at ",pos $str,"\n"; } while ($str =~ /T/ig) { $T++; print"\n T=$T ends at ",pos $str,"\n"; } my $output="Results.txt"; # Line 8 open(my $fh, ">", $output) or die "Cannot open file '$output'.\n\n"; $A=0; $T=0; while ($str=~ /A/ig) { $A++; print $fh "\n A=$A ends at ",pos $str,"\n"; } while ($str=~ /T/ig) { $T++; print $fh "\n T=$T ends at ",pos $str,"\n"; }