#!C:\Perl use strict; BEGIN{ @ARGV=map glob, @ARGV; } open(RES, ">>results.txt"); print RES "File Number A A% B B% Null Null%\n"; my $A=0; #these three lines set my initial counts at zero my $B=0; my $null=0; my $filenum=0; while (<>){ chomp($_); if ($_ eq "stringa"){ $A++;} elsif ($_ eq "stringb"){ $B++;} else { $null++; } } my $popa=$A/1000; #these lines determine what percent of the population the strings represent my $popa=sprintf('%.2f',$popa); #cut the percentages to two decimal places my $popb=$B/1000; my $popb=sprintf('%.2f',$popb); my $popnull=$null/1000; my $popnull=sprintf('%.2f',$popnull); my $filenum++; #Add one to my filenumber print RES "$filenum $A $popa $B $popb $null $popnull\n"; #print the results out to the "results" file