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

Re: [MacPerl] Syntax error question (newbie)



That sure is a weird loop.  Have you considered writing it like this?

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

Anyway, the only thing that sticks out in your code is this:

  $prova =  @ID[$i];

It should be:

  $prova =  $ID[$i];

But that's probably not causing the problem you're seeing.  Not sure what the
problem is, I feel like there's something else going on, like the code outside
these snippets is different or something.



valoti@irfmn.mnegri.It (Giorgio Valoti) wrote:
>Hi All!
>checking the sintax of this piece of script:
>
>for ($i = 0;
>     $i <= $#ID;
>     $i++) {
>  $prova =  @ID[$i];
>  print ("$prova\n");
>  foreach $x (0..$#ID) {
>    if ($ID[$x] !~ /[$prova]/) {
>      print ("$ID[$x]\n");
>
>    }
>  }
>}
>
>everything's OK.
>
>but if I use:
>for ($i = 0;
>     $i <= $#ID;
>     $i++) {
>  $prova =  @ID[$i];
>  print ("$prova\n");
>  foreach $x (0..$#ID) {
>    if ($ID[$x] !~ /[$prova]/) {
>      print ("--- $ID[$x]\n");        #that's changed
>
>    }
>  }
>}
>
>I have:
># Can't open perl script "Voivod I:": No such file or directory.
>Am I missing something obvious?
>
>TIA
>
>Giorgio
>
>===== Want to unsubscribe from this list?
>===== Send mail with body "unsubscribe" to macperl-request@macperl.org
>

  -------------------                            -------------------
  Ken Williams                             Last Bastion of Euclidity
  ken@forum.swarthmore.edu                            The Math Forum



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