Skip to content

Instantly share code, notes, and snippets.

@tokuhirom
Forked from kanonji/Bar.pm
Created June 8, 2011 07:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tokuhirom/1013957 to your computer and use it in GitHub Desktop.
Save tokuhirom/1013957 to your computer and use it in GitHub Desktop.
perl ./once.pl is ok. perl ./twice.pl is not ok. Use 0.20110401 of Number::Phone::JP.
diff --git a/lib/Number/Phone/JP/Table.pm b/lib/Number/Phone/JP/Table.pm
index ddca7c4..9e26380 100644
--- a/lib/Number/Phone/JP/Table.pm
+++ b/lib/Number/Phone/JP/Table.pm
@@ -5,7 +5,6 @@ use warnings;
use base qw(Exporter);
our $VERSION = '0.20110401';
-our @EXPORT = qw(%TEL_TABLE);
require Number::Phone::JP::Table::Class1;
require Number::Phone::JP::Table::Class2;
@@ -35,6 +34,13 @@ our %TEL_TABLE = (
%Number::Phone::JP::Table::Fmc::TEL_TABLE,
);
+sub import {
+ my $class = shift;
+ my $pkg = caller(0);
+ no strict 'refs';
+ %{"$pkg\::TEL_TABLE"} = %TEL_TABLE;
+}
+
1;
__END__
use strict;
use warnings;
use utf8;
use Test::More tests => 1;
{
package Foo;
use Number::Phone::JP;
use Number::Phone::JP;
sub invoke {
my ( $self ) = @_;
my $ins = Number::Phone::JP->new;
my $result = $ins->set_number('03-5321-1111')->is_valid_number;
return $result;
}
}
is(Foo::invoke(), 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment