splicing an array



Hi all,

I've an array of about 300 elements. I want to splice 7 elements at the
time, process this and then splece another 7 elemnts untill the end:

first ploblem if I use the scann_array function, perl say:

main::scann_array() called too early to check prototype at
G:\addresse\scrape.pl line 36.

and I don't know what that mean.

Ok I changed this an call splice in the while loop,

my ($name,$rub,$nl,$addr,$map,$tet,$capital) = splice(@a, 0,6);

but then perl says:

Use of uninitialized value in concatenation (.) or string at
G:\addresse\scrape.pl line 37, <FILE> line 106.
106 is the last line of the file, and this error appear at the end of
the execution, many times, but also in the middle of the output

Thanks.
Xbiton

----------------------------------
my @file = glob("*.eu");

foreach my $f (@file){
open(FILE, "$f");
my @a =();
@a =<FILE>;
my $count =@a;

while(@a){
my ($name,$rub,$nl,$addr,$map,$tet,$capital) =
scann_array(@a);
print "$name,$rub,$nl,$addr,$map,$tet,$capital";
}


}

sub scann_array(\@){
return splice(@{$_[0]},0,6);
}

.



Relevant Pages

  • Re: random array elements and speed
    ... JJ> than splice for large arrays but slower for small arrays. ... and swap/pop is several perl ops. ... a loop with a list of sizes and use my code changes (you want to compare ...
    (comp.lang.perl.misc)
  • Re: FAQ 4.48 How do I shuffle an array randomly?
    ... >> You've probably seen shuffling algorithms that work using splice, ... >> This is bad because splice is already O, and since you do it N times, ... No, Perl is too atypical:) ... large N to even see the quadratic behavior. ...
    (comp.lang.perl.misc)
  • Re: Insert Multiple Lines after a Specified Line -- Please Help!
    ... ap> I am new to PERL I am trying to automate ... ap> some file manipulation techniques. ... splice in new lines with perl's normal array stuff. ...
    (comp.lang.perl.misc)
  • Re: a splice question
    ... >> will only live in this expression) of the lines in the file that splice ... JWK> Or use a list slice (instead of copying the list to an array.) ... Search or Offer Perl Jobs ...
    (comp.lang.perl.misc)
  • Re: random array elements and speed
    ... Uri Guttman wrote: ... JJ> than splice for large arrays but slower for small arrays. ... and swap/pop is several perl ops. ...
    (comp.lang.perl.misc)