u235sentinel wrote: > I'm a newbie to perl also. Been workign with it for a whole 2 weeks > now. Actually.. make that 3 ::grinz:: > > Warning.. lengthy email below.. I beg forgiveness in advance :-)
Length isn't a problem. There are some problems here, though, because you are not addressing the issues that are holding him back. One is the syntax for accessing an array element. Array elements should be accessed as scalars, with the scalar notation: my $element = $array1[$index]; That is a major source of the problems the OP found. The other is that he expects the print statement to automatically space the output. It won't. > > Ok. Here is what I did. Some things you should have done inline: > #!/usr/bin/perl use strict; # *always* use warnings; # until you canotherwise catch the things you get warnings about. > > > @array1[0..5] = 1; Means nothing, AFAIK. Greetings! E:\d_drive\perlStuff>perl -w -Mstrict my @Array1; @Array1[0..5] = 1; print "$_\n" for @Array1; ^Z 1 Use of uninitialized value in concatenation (.) or string at - line 3. Use of uninitialized value in concatenation (.) or string at - line 3. Use of uninitialized value in concatenation (.) or string at - line 3. Use of uninitialized value in concatenation (.) or string at - line 3. Use of uninitialized value in concatenation (.) or string at - line 3. Try instead: $_ = 1 for @array[0..4]; > > @total[0] = 0; > > for($i=0; $i<4; $i++) > { > if($i == 0) > { > @total[$i] = @array1[$i]; > print "First group"; > print @total[$i]; > } > else > { > $j = $i - 1; > print "Second group"; > @total[$i] = @total[$j] + @array1[$i]; > print @total[$i]; > } > } > > When I run it I get the following: You both need to start by using strict and warnings. It will also help if you use variable names that tell you somethng about what you are trying to do. I'd suggest the OP start by using strict, and using the proper syntax to address elements of an array. Then post when he he gets satuck. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>