[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Syntax error question (newbie)




>From: Bruce Van Allen <bva@cruzio.com>

> @ID[$i] gives a slice of the array @ID, in this case a one-element
> slice. By asking for its value in scalar context (by assigning it to
> $prova), what you get is the number of elements, (1). In almost all
> cases where one would use the C-ish structure
>
>  for ($i = 0; $i <= $#ID; $i++) { ...
>
> one really wants to process the scalar (string-like) contents of the
> i-th item of the array @ID, which is expressed $ID[$i] (note the
> $-sign before ID).

Oops! Only myself to blame; you know, it's really my first script. Anyway,
many thanks to all! But what really bugs me is that I have pasted again my
original and it's OK! Only God knows...
So I'll use the Ken's suggestion:

foreach my $prova (@ID) {
  print ("$prova\n");
  foreach my $other (@ID) {
    if ($other !~ /[$prova]/) {
      print ("$other\n");
    }
  }
}

Thanks again

Giorgio

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org