A sample of what I received: File# A B C 1 5 6 3 What I wanted: File# A B C 1 2 1 0 2 2 4 2 3 1 1 1This is my code:
What am I doing wrong? Edit: Thanks for the help so far!#!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 populatio +n the strings represent my $popa=sprintf('%.2f',$popa); #cut the percentages to two decimal pl +aces 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 $pop +null\n"; #print the results out to the "results" file
In reply to Re^2: Piping many individual files into a single perl script
by kelder
in thread Piping many individual files into a single perl script
by kelder
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |