Subject: | Perl6::Say does not export on second use. |
Perl6::Say only exports into the package which loads the module. It does not export into subsequent "use"s. This is because it has no import() method.
package Foo;
use Perl6::Say;
say "Foo";
package Bar;
use Perl6::Say;
say "Bar"; # error
The attached patch fixes this.
I also notice the 1.t test was complaining about "use of uninitialized value in open" and fixed that.
--- /dev/null 2005-03-10 15:09:17.000000000 -0800
+++ t/export.t 2005-03-10 15:05:49.000000000 -0800
@@ -0,0 +1,17 @@
+#!/usr/bin/perl -w
+
+# Check that Perl6::Say exports properly. It didn't.
+
+use Test::More tests => 2;
+
+
+package Foo;
+use Perl6::Say;
+
+::can_ok 'Foo', 'say';
+
+
+package Bar;
+use Perl6::Say;
+
+::can_ok 'Bar', 'say';
\ No newline at end of file
--- MANIFEST 2004-03-25 14:00:02.000000000 -0800
+++ MANIFEST 2005-03-10 15:05:32.000000000 -0800
@@ -4,3 +4,4 @@
README
Say.pm
t/1.t
+t/export.t
--- Say.pm 2004-03-28 05:11:43.000000000 -0800
+++ Say.pm 2005-03-10 15:07:05.000000000 -0800
@@ -4,12 +4,16 @@
# Handle direct calls...
-*{caller().'::say'} = sub { print @_, defined $\ ? "" : "\n" };
+sub say { print @_, defined $\ ? "" : "\n" };
# Handle OO calls:
sub IO::Handle::say { my ($fh) = shift; print {$fh} @_, defined $\ ? "" : "\n" }
+sub import {
+ *{caller().'::say'} = \&say;
+}
+
1;
__END__
--- t/1.t 2004-03-26 20:14:11.000000000 -0800
+++ t/1.t 2005-03-10 15:05:15.000000000 -0800
@@ -1,3 +1,5 @@
+#!/usr/bin/perl -w
+
use Test::More no_plan;
BEGIN { use_ok('Perl6::Say') };
@@ -7,7 +9,7 @@
Test::Builder->current_test(4);
-my $str;
+my $str = '';
open FH, '>', \$str;
ok( (say FH 'what'), 'Indirectly said: "what"' );