#!/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 input to end list\n"; my @scope_ct = (); while ( $input = ) { 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 list 4 5 6 Enter individual count from scope. Press Enter without input to end list 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