I agree with frozenwithjoy that you should use strict;. Always do that and also use warnings;

I did encounter an error when running your code, so I made just a few changes. One is replacing the C-style for loops with something a bit more Perlish. Also used List::Util to sum @scope_ct:

#!/usr/bin/perl -w use strict; use warnings; use bignum; use List::Util qw/sum/; # 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"; # } my @arr; print "Enter number of counts.\n->"; chomp( my $count = <> ); print "\n$count\n"; for ( 1 .. $count ) { print "Enter individual count from scope. Press Enter without input to end +list.\n"; my $count_i = indiv_count(); push @arr, $count_i; } print "The counts were:\n"; print "Count number $_ was $arr[$_-1]\n" for 1 .. @arr; sub indiv_count { my @scope_ct; while ( chomp( my $input = <> ) ) { last if $input =~ /^\s*$/; push @scope_ct, $input; } my $scope_ct = @scope_ct; my $cell_sum = sum @scope_ct; my $cell_ct = ( $cell_sum / $scope_ct ) / 0.0000015; return $cell_ct; }

Didn't encounter any more errors, but I may not have sufficiently tested it.

Hope this helps!


In reply to Re: Bug in code by Kenosis
in thread Bug in code by disulfidebond

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.