Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

local %MYPKG::; doesn't work #815

Closed
p5pRT opened this issue Nov 4, 1999 · 2 comments
Closed

local %MYPKG::; doesn't work #815

p5pRT opened this issue Nov 4, 1999 · 2 comments

Comments

@p5pRT
Copy link

p5pRT commented Nov 4, 1999

Migrated from rt.perl.org#1743 (status was 'resolved')

Searchable as RT1743$

@p5pRT
Copy link
Author

p5pRT commented Nov 4, 1999

From rnewman@northernlight.com

  local %MYPKG​:: ;

should localize, and set to undef, all variables in
the MYPKG package, but it doesn't appear to do anything
at all.

Test Case​:

The following program prints
""
"green"
"green"
"blue"
"blue"

when it should print
""
"green"
""
"blue"
"green"

(Notice what happens if you change
  local %MYPKG​:: ;
to
  local $MYPKG​::COLOR ;
)

#!/usr/bin/perl
use strict;
no strict 'refs';
package MYPKG;
use vars '$COLOR';

sub foo {
  local %MYPKG​:: ;
  dumpit();
  $COLOR = "blue";
  dumpit();
}

sub dumpit {
  print qq("), $COLOR, qq("\n);
}

dumpit();
$COLOR = "green";
dumpit();
foo();
dumpit();


Site configuration information for perl 5.00404​:

Configured by mark at Sun Dec 21 15​:23​:48 EST 1997.

Summary of my perl5 (5.0 patchlevel 4 subversion 4) configuration​:
  Platform​:
  osname=solaris, osvers=2.6, archname=sun4-solaris
  uname='sunos localhost 5.6 generic sun4m sparc sunw,sparcstation '
  hint=recommended, useposix=true, d_sigaction=define
  bincompat3=y useperlio=undef d_sfio=undef
  Compiler​:
  cc='gcc', optimize='-O', gccversion=2.7.2.3
  cppflags='-I/usr/local/include'
  ccflags ='-I/usr/local/include'
  stdchar='unsigned char', d_stdstdio=define, usevfork=false
  voidflags=15, castflags=0, d_casti32=define, d_castneg=define
  intsize=4, alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries​:
  ld='gcc', ldflags =' -L/usr/local/lib'
  libpth=/usr/local/lib /lib /usr/lib /usr/ccs/lib
  libs=-lsocket -lnsl -lgdbm -ldl -lm -lc -lcrypt
  libc=/lib/libc.so, so=so
  useshrplib=false, libperl=libperl.a
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
  cccdlflags='-fpic', lddlflags='-G -L/usr/local/lib'

Locally applied patches​:


@​INC for perl 5.00404​:
  /usr/local/lib/perl5/sun4-solaris/5.00404
  /usr/local/lib/perl5
  /usr/local/lib/perl5/site_perl/sun4-solaris
  /usr/local/lib/perl5/site_perl
  .


Environment for perl 5.00404​:
  HOME=/usr/rnewman
  LANG=C
  LD_LIBRARY_PATH (unset)
  LOGDIR (unset)
 
PATH=/usr/dt/bin​:/usr/openwin/bin​:/bin​:/usr/bin​:/usr/ucb​:/usr/local/bin​:/usr/ccs/bin​:/usr/rnewman/Office51/bin​:/usr/local/si/mkssi/sol2​:.
  PERL_BADLANG (unset)
  SHELL=/usr/local/bin/tcsh

@p5pRT
Copy link
Author

p5pRT commented Nov 4, 1999

From [Unknown Contact. See original ticket]

Ron Newman writes​:

The declaration

local %MYPKG​:: ;

should localize, and set to undef, all variables in
the MYPKG package, but it doesn't appear to do anything
at all.

Why? You manipulate symbol table, not variables. Variables in a
*compiled* code are not accessed via symbol tables.

#!/usr/bin/perl -wl

$MYPKG​::foo = 11;
print defined $MYPKG​::foo;
local %MYPKG​:: ;
print defined $MYPKG​::foo;
print not defined ${"MYPKG​::foo"};

does what I expect.

Ilya

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant