I guess i DO understand now! Thats really cool, was wondering about that for quite a 
while... I i did understand it right, i have a new scope inside the loop, but if i 
roll through the array, or hash i alwas!! refer to the variable defined in the main 
program, right? 

Nice of you! Itīs been a real Help! 

btw, what is the 3D thing in "$n =3D $_;" ? I saw it quite often, but never knew...

If you can describe it to me, you are my "king of the week" and i wonīt bother you 
again...

Greets Johannes

p.s.: have a nice weekend!

On Sep 20, Theuerkorn Johannes said:

>wow, it=B4s been only the my %values declared outside the loop... But why
>has it to be declared inside, i thougt its "global" if I use it outside?
>Isn,t it?

The problem is with using a reference to %values.

Here's an example:

  my ($n, @list);

  for (1, 2, 3, 4) {
    $n =3D $_;
    push @list, \$n;
  }

  for (@list) {
    print "$$_ ";  # prints 4 4 4 4
  }

The reasons each element of @list holds the SAME reference is because
they're ALL references to the SAME $n.  If you move the declaration of $n
into the loop, Perl will allocate a new $n each time:

  my @list;

  for (1, 2, 3, 4) {
    my $n =3D $_;
    push @list, \$n;
  }

  for (@list) {
    print "$$_ ";  # prints 1 2 3 4
  }

--=20
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]      

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to