eff_i_g has asked for the wisdom of the Perl Monks concerning the following question:
the file:package MyPackage; use Symbol qw( gensym ); ... sub import { MyPackage->export_to_level(1, @_); } sub open_file { my ($handle, $file) = @_; ${$handle} = gensym(); open *${$handle}, $file || die; import(*${$handle}); # this apparently isn't working? }
use MyPackage; use strict; ... open_file('LOG', 'log.txt'); while (<$LOG>) { print; } # yields the following: Global symbol "$LOG" requires explicit package name at ./moduletest.pl + line 21. Execution of ./moduletest.pl aborted due to compilation errors.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: modules, exporting, and indirect filehandles
by ikegami (Patriarch) on Aug 09, 2005 at 19:58 UTC | |
by eff_i_g (Curate) on Aug 09, 2005 at 20:09 UTC | |
by ikegami (Patriarch) on Aug 09, 2005 at 20:23 UTC | |
by chromatic (Archbishop) on Aug 09, 2005 at 20:31 UTC | |
by ikegami (Patriarch) on Aug 09, 2005 at 20:35 UTC | |
by eff_i_g (Curate) on Aug 09, 2005 at 21:11 UTC | |
by eff_i_g (Curate) on Aug 09, 2005 at 20:19 UTC | |
|
Re: modules, exporting, and indirect filehandles
by Transient (Hermit) on Aug 09, 2005 at 19:42 UTC |