diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2000-11-29 17:01:41 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2000-11-29 17:01:41 +0000 |
commit | 22633ac4d822d56571390c6ca915a7e5a37ef483 (patch) | |
tree | 7a229098a02d887af8309fe151515ac7d0bd426e | |
parent | ee28235b3274e2a0a6e2b8de32573633563eef75 (diff) | |
download | perl-22633ac4d822d56571390c6ca915a7e5a37ef483.tar.gz |
Make the Class::Struct import() wiser.
p4raw-id: //depot/perl@7926
-rw-r--r-- | lib/Class/Struct.pm | 10 | ||||
-rw-r--r-- | t/lib/class-struct.t | 3 |
2 files changed, 9 insertions, 4 deletions
diff --git a/lib/Class/Struct.pm b/lib/Class/Struct.pm index 14d28fa4ac..185a8ff142 100644 --- a/lib/Class/Struct.pm +++ b/lib/Class/Struct.pm @@ -54,10 +54,14 @@ sub printem { sub import { my $self = shift; - if ( @_ % 2 == 0 ) { - &struct; - } else { + if ( @_ == 0 ) { $self->export_to_level( 1, $self, @EXPORT ); + } elsif ( @_ == 1 ) { + # This is admittedly a little bit silly: + # do we ever export anything else than 'struct'...? + $self->export_to_level( 1, $self, @_ ); + } else { + &struct; } } diff --git a/t/lib/class-struct.t b/t/lib/class-struct.t index 22801d5700..26505bacfc 100644 --- a/t/lib/class-struct.t +++ b/t/lib/class-struct.t @@ -15,7 +15,8 @@ sub meth { 42 } package MyObj; -use Class::Struct 'struct'; +use Class::Struct; +use Class::Struct 'struct'; # test out both forms use Class::Struct SomeClass => { SomeElem => '$' }; |