Hi kgherman,
The following code, returns a value of 67 . . .
This code doesn't compile. You should always use strict; and use warnings;, even in example code, then you won't forget to include something like the package that holds your max() ...
In order to get the results you want from the array you have, you need:
. . . I'm not sure what the rest of your code is for; please feel free to explain what you are really trying to do. Maybe you were trying to do something like this?splice(@array,1,2);
#!/usr/bin/perl use strict; use warnings; my @array = ( 99999, 34, 67, 976, 432, 99999 ); my $elements = @array; for ( my $offset = 0; $offset < $elements; $offset++ ) { for ( my $length = 0; $length <= $elements; $length++ ) { my @to_splice = @array; my @spliced = splice @to_splice, $offset, $length; print "splice(\@array, $offset, $length) : @spliced\n"; } }
Upate: added example
In reply to Re: Sub-setting an Array
by 1nickt
in thread Sub-setting an Array
by kgherman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |