in reply to Re: Print function
in thread Print function

Thank you for responding. I very much appreciate it as I'm a complete novice at this. I am sorry if I'm not more clear. When I was referring to line #921, what I was trying to say is that there are approximately 900 lines of blank space between where my output ends and the totals are printed when I place the total print statement outside the initial while loop. If I place the print statement for the count inside the while statement, it prints the statements approximately 900 times. I cannot figure out why it is doing this. I would prefer to print totals after each different company is printed.

Replies are listed 'Best First'.
Re^3: Print function
by Jenda (Abbot) on Sep 02, 2008 at 16:22 UTC

    Are those lines empty or full of tab characters? Maybe the CytokineArrays.txt file ends by some 900 empty lines. Try to add

    next unless /\S/;
    after the chomp; in the second loop.

    Also, there is no difference between $var =~ /\S+/ and $var =~ /\S/. Except that the later will probably be quicker. Both return true whenever there is at least one non-whitespace-character anywhere in the $var. Same with the \d. Maybe you wanted $var =~ /^\S+$/. Which means ... make sure the $var contains only non-whitespace-characters and is not empty.

    Update: fixed the typo noticed by jwkrahn. I meant \S+ and wrote \s+.

      Maybe you wanted $var =~ /^\s+$/. Which means ... make sure the $var contains only non-whitespace-characters and is not empty.

      I think that you meant $var =~ /^\S+$/ for non-whitespace-characters?

      Thank you very much. That did the trick.