Perl: Confusion About A Little Piece Of Code

  • From: "Homme, James" <james.homme@xxxxxxxxxxxx>
  • To: "programmingblind@xxxxxxxxxxxxx" <programmingblind@xxxxxxxxxxxxx>
  • Date: Wed, 11 May 2011 10:11:23 -0400

Hi,
Maybe I'm not understanding this. Here is some code.
print "Enter some numbers on separate lines: ";
my $user_total = total(<STDIN>);

I'm pretending that there's a subroutine that adds up the numbers.

I'm thinking that I would enter the numbers from the keyboard on separate 
lines, and when I'm done, I'd press the key combination that signals end of 
input.

When the program gets the array, I'm thinking that each line would have a new 
line on the end of it.

Here's where the question comes in.

Would the subroutine need to use the chomp function to get rid of the new lines 
before it adds up the numbers, or would it be happy with the line endings?

Thanks.

Jim
Jim Homme,
Usability Services,
Phone: 412-544-1810.


________________________________
This e-mail and any attachments to it are confidential and are intended solely 
for use of the individual or entity to whom they are addressed. If you have 
received this e-mail in error, please notify the sender immediately and then 
delete it. If you are not the intended recipient, you must not keep, use, 
disclose, copy or distribute this e-mail without the author's prior permission. 
The views expressed in this e-mail message do not necessarily represent the 
views of Highmark Inc., its subsidiaries, or affiliates.

Other related posts:

  • » Perl: Confusion About A Little Piece Of Code - Homme, James