in reply to Re: (tye)Re: Variable scoping in packages
in thread Variable scoping in packages
Now write a program:package Pack; my $foo = 'pack'; sub import { my $pkg = caller(); no strict 'refs'; *{ $caller . '::foo' } = \$foo; } 1;
After realizing that names have scope, variables do not (Dominus once said something similar), print out this page. Then eat it. :) ©#!/usr/bin/perl -w use strict; use Pack; print "$foo\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: (tye)Re: Variable scoping in packages
by blakem (Monsignor) on Oct 10, 2001 at 04:03 UTC | |
|
Re: Re: Re: (tye)Re: Variable scoping in packages
by John M. Dlugosz (Monsignor) on Oct 10, 2001 at 08:09 UTC |