trying to learn

Ritesh Raj Sarraf <[email protected]> Fri, 3 Sep 2004 12:15:25 +0545 (NPT)
Newsgroups gmane.user-groups.linux.delhi.devel
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello everyone,
 	While learning perl came across this problem, someone please
 	help me understand it clear.

 	This program is a simple exercise program from one of the perl
 	books where multiple numbers separated by spaces and entered on
 	separate lines (you'll understand it easily if you read the code
 	below). The desired output is to have sum total of the number of
 	each line and a grand total of all the lines.

 	Below is my incomplete source code. I tried taking multiple
 	lines into an array and then split them. In the for loop I want
 	my new array name to be assigned at runtime like @line1, @line2
 	and so..
 	How do I do that ? Or is my procedure incorrect to get the
 	desired output ??   Please help

rrs


#!/usr/bin/perl
#
#
print "Please enter multiple numbers separated by spaces on multiple lines.\n";
print "When finished, Press CTRL + D\n";
@numbers = <STDIN>;

@all_lines = split(/\n/, @numbers);

$count = 0;
$number_of_lines = @all_lines;
@string_array = (1..9);

for(; $count <= $number_of_lines; $count++)
{
 	@line.($count + 1) = @all_lines[$count];

}
# Now we sum up each line.
#
#$line1total = 0;
#for ($count = 0; $count <=

- -- 
Ritesh Raj Sarraf
RESEARCHUT -- http://www.researchut.com
Gnupg Key ID: 04F130BC
"Stealing logic from one person is plagiarism, stealing from many is research".
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Made with pgp4pine 1.76

iD8DBQFBOA+G4Rhi6gTxMLwRAu4bAKCXk38dOyyOahLC4vrQ7k65Qncy4wCePHkI
xlERJR20kTWuYQhBGmqLWbw=
=UaeF
-----END PGP SIGNATURE-----