Try it with: $var1= "joe"; # a package var instead of: my $var1 = "joe"; # a lexical var You can not get to the 'my' vars of one package from another. ----- Original Message ----- From: "Todd Wells" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, February 27, 2001 6:02 PM Subject: setting a variable in another namespace > I'm having some difficulty doing this and I'm not quite sure why. > > I'd like to allow a module to set a variable in the main routine that calls > it. > > I must be doing something fundamentally wrong here. > > Here's what I'm doing (in way of an example, not my specific case): > > #test.pl > use MyModule; > my $var1 = "joe"; > MyModuleSub(); > print "$var1\n"; > #end test.pl > > #MyModule.pm > package MyModule; > use Exporter; > @ISA = ('Exporter'); > @EXPORT = qw(&MyModuleSub); > > sub MyModuleSub{ > $main::var1 = "bill"; > } > 1; > #end MyModule.pm > > However, "joe" is always printed when I run test.pl. > > I've also tried this cookbook variation of MyModuleSub and it doesn't seem > to work like I expect, either: > > sub MyModuleSub{ > no strict 'refs'; > my caller = caller(); > $ {$caller . "::var1" } = "bill"; > } > > Any help is appreciated... > > -Todd > _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users