Re: [LIP] trying to learn
Swaroop C H <g2swap-linuxindiaprogrammers-/[email protected]>
| Newsgroups | gmane.user-groups.linux.india.programmers |
|---|---|
| Message-ID | <[email protected]> |
> @line.($count + 1) = @all_lines[$count];
you can't do this. variable names cannot be created like that.
here's something i whipped up that might work like u expect:
#################################################################
#!/usr/bin/env perl
use warnings;
use strict;
my @lines; # store all lines
print "Enter the numbers\n";
while (my $line = <STDIN>)
{
my @numbers = split / /, $line; # splits on whitespace
push @lines, \@numbers; # array of references to arrays
}
# now do the counting
my $allsum = 0;
for my $line(@lines)
{
my $linesum = 0;
for my $number(@$line) # for each number in the array
{
$linesum += $number;
$allsum += $number;
}
print "Line sum = $linesum\n";
}
print "All sum = $allsum\n";
#################################################################
If you have any doubts, i'll try to help you out.
(probably better to mail me off-list)
HTH,
Swaroop
=====
Check out my "website reloaded" - http://www.g2swaroop.net !
-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click