summaryrefslogtreecommitdiff
path: root/lib/FileCache.pm
diff options
context:
space:
mode:
authorJos I. Boumans <kane@dwim.org>2004-12-08 15:24:19 +0100
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2004-12-08 16:19:38 +0000
commit02c473a9139e94d6158d1e3dd9a912f3525b3b21 (patch)
treeadac38cd67e7893db531aea52b5279e409513741 /lib/FileCache.pm
parentb7a91edcc80cb05776e70aedec8ffa365b6d6806 (diff)
downloadperl-02c473a9139e94d6158d1e3dd9a912f3525b3b21.tar.gz
Re: [perl #32949] FileCache only works in "main" package
From: "Jos I. Boumans" <kane@xs4all.net> Message-Id: <7728A4F5-491C-11D9-9CA3-000A95EF62E2@xs4all.net> p4raw-id: //depot/perl@23627
Diffstat (limited to 'lib/FileCache.pm')
-rw-r--r--lib/FileCache.pm20
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/FileCache.pm b/lib/FileCache.pm
index b1a30dec3a..a64ed9a86b 100644
--- a/lib/FileCache.pm
+++ b/lib/FileCache.pm
@@ -84,15 +84,27 @@ no strict 'refs';
# These are not C<my> for legacy reasons.
# Previous versions requested the user set $cacheout_maxopen by hand.
# Some authors fiddled with %saw to overcome the clobber on initial open.
-use vars qw(%saw $cacheout_maxopen);
+use vars qw(%saw $cacheout_maxopen @EXPORT);
my %isopen;
my $cacheout_seq = 0;
sub import {
my ($pkg,%args) = @_;
- $pkg = caller(1);
- *{$pkg.'::cacheout'} = \&cacheout;
- *{$pkg.'::close'} = \&cacheout_close;
+
+ # Not using Exporter is naughty.
+ # Also, using caller(1) is just wrong.
+ #$pkg = caller(1);
+ #*{$pkg.'::cacheout'} = \&cacheout;
+ #*{$pkg.'::close'} = \&cacheout_close;
+
+ # Use Exporter. %args are for us, not Exporter.
+ # Make sure to up export_to_level, or we will import into ourselves,
+ # rather than our calling package;
+ use base 'Exporter';
+ @EXPORT = qw[cacheout cacheout_close];
+
+ __PACKAGE__->export_to_level(1);
+ Exporter::import( $pkg );
# Truth is okay here because setting maxopen to 0 would be bad
return $cacheout_maxopen = $args{maxopen} if $args{maxopen};