in reply to Global vars not accessable globaly

Those global variables are accessible globally. What you've got is a think-o. Take for example
use vars qw[ @foo1 @foo2 ]; use Data::Dumper; { my $bar = 666; @foo1 = $bar; } { @foo2 = 666; @foo1 = 123; } die Dumper( \@foo2, \@foo1 ); __END__ $VAR1 = [ 666 ]; $VAR2 = [ 123 ];
Any idea why @foo1 doesn't contain 666 and 123?

MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
** The third rule of perl club is a statement of fact: pod is sexy.

Replies are listed 'Best First'.
Re^2: Global vars not accessable globaly
by theroninwins (Friar) on Sep 20, 2004 at 09:11 UTC
    Nice example but doesn't really help a bit more plain text would be better. and what is a think-o?
    Oh and the content of final1 in that statement is correct. When i print it there it works just fine.
      Nice example but doesn't really help a bit more plain text would be better
      Can you answer why @foo1 doesn't contain 666 and 123?

      In your original question you say the array final1 and final2 are declared as global but i can only print them in there function. the print @final1 just below that and the print at the end do not work..... .

      • "It doesn't work" is not a very good explanation (some would say it is not an explanation at all) (How (Not) To Ask A Question)
      • my snippet demonstrates why @final1 and @final2 don't contain what you expect. @foo1 = 123; is not the same as push @foo1, 123;
      what is a think-o?
      Its a brain fart (dict thinko)

      MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
      I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
      ** The third rule of perl club is a statement of fact: pod is sexy.

      @array = 1; print "@array"; 1 @array = 2; print "@array"; 2 @array = 1; push @array, 2; print "@array"; 1 2

      Examine what is said, not who speaks.
      "Efficiency is intelligent laziness." -David Dunham
      "Think for yourself!" - Abigail
      "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon