My first recommendation is that you need
use strict; in your code. This will REALLY help with the debugging.
Second: don't use the same name for scalars and arrays (e.g., my $scope_ct = @scope_ct;). It is too easy to make a mistake w/o realizing it.
EDIT: I made a few very minor changes based on the errors from using strict/warnings and now your script seems to work (see below). If I were you, I'd still go back and rename some variables to make your script easier to expand/maintain/troubleshoot in the future.
#!/usr/bin/env perl
use strict;
use warnings;
use bignum;
# pseudocode
# print "Enter number of counts"
# $ct = <>;
# @arr = ();
# for ($i = 0; $i < $ct; $i++) {
# each iteration of loop calls subroutine
# to get cell counts from user and stores in variable
# push() variable to store in array
# $count_i = &indiv_count()
# push (@arr, $count_i);
# }
# output @arr
# $arr_len = @arr;
# print "The counts were:\n";
# for ($j = 0; $j< $arr_len; $j++) {
# print "Count number $j was arr[$j]\n";
# }
print "Enter number of counts.\n->";
my $ct = <>;
chomp $ct;
print "\n$ct";
my @arr = ();
for ( my $i = 0 ; $i < $ct ; $i++ ) {
my $count_i = &indiv_count();
push( @arr, $count_i );
}
my $arr_len = @arr;
print "The counts were:\n";
for ( my $j = 0 ; $j < $arr_len ; $j++ ) {
my $iteration = $j + 1;
print "Count number $iteration was $arr[$j]\n";
}
sub indiv_count {
my ($input);
print "Enter individual count from scope. Press Enter without inp
+ut to end list\n";
my @scope_ct = ();
while ( $input = <STDIN> ) {
chomp $input;
last if ( $input =~ /^\s*$/ );
push( @scope_ct, $input );
}
my $cell_sum;
my $scope_ct = @scope_ct;
for ( my $i = 0 ; $i < $scope_ct ; $i++ ) {
$cell_sum += pop(@scope_ct);
}
my $cell_ct = ( ( $cell_sum / $scope_ct ) / 0.0000015 );
return $cell_ct;
}
__END__
$ ./cell_counter.pl
Enter number of counts.
->3
3Enter individual count from scope. Press Enter without input to end
+list
1
2
3
Enter individual count from scope. Press Enter without input to end l
+ist
4
5
6
Enter individual count from scope. Press Enter without input to end l
+ist
7
8
9
10
The counts were:
Count number 1 was 1333333.333333333333333333333333333333333
Count number 2 was 3333333.333333333333333333333333333333333
Count number 3 was 5666666.666666666666666666666666666666667