Thanks in advance,Example 1: ========================= Sample.pl: ---------- #!/usr/bin/perl -w use strict; use Zoo; print $pet, "\n"; Zoo.pm: ------- package Zoo; our $pet = "Cat"; sub import { my $package = shift; my ($callerpkg, $file, $lineno) = caller; ################# # Type-glob below ################# *{"${callerpkg}::pet"} = \${"${package}::pet"}; } 1; Output: ------- >./sample.pl Cat ========================= Example 2: ========================= Sample.pl: ---------- #!/usr/bin/perl -w use strict; use Zoo; print $pet, "\n"; Zoo.pm: ------- package Zoo; our $pet = "Cat"; sub import { my $package = shift; my ($callerpkg, $file, $lineno) = caller; #################### # Symbolic reference below #################### ${"${callerpkg}::pet"} = ${"${package}::pet"}; } 1; Output: ------- >./sample.pl Variable "$pet" is not imported at ./sample.pl line 6. Global symbol "$pet" requires explicit package name at ./sample.pl lin +e 6. Execution of ./sample.pl aborted due to compilation errors. =========================
In reply to Use of typeglob in package import subroutine by GG1985
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |