From: Jarkko Hietaniemi Date: Wed, 29 Nov 2000 17:01:41 +0000 (+0000) Subject: Make the Class::Struct import() wiser. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=22633ac4d822d56571390c6ca915a7e5a37ef483;p=p5sagit%2Fp5-mst-13.2.git Make the Class::Struct import() wiser. p4raw-id: //depot/perl@7926 --- diff --git a/lib/Class/Struct.pm b/lib/Class/Struct.pm index 14d28fa..185a8ff 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 22801d5..26505ba 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 => '$' };