Changeset 2261

Show
Ignore:
Timestamp:
12/02/07 00:55:53 (13 months ago)
Author:
charsbar
Message:

lang/perl/Acme-StrictAndWarnings?: improved unimport

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/Acme-StrictAndWarnings/trunk/lib/Acme/StrictAndWarnings.pm

    r2258 r2261  
    1212); 
    1313 
    14 sub import { 
    15     shift; 
    16  
     14sub _parse_args { 
    1715    my @strict; 
    1816    my @warnings; 
     
    2422        } 
    2523    } 
     24    return { strict => \@strict, warnings => \@warnings }; 
     25} 
    2626 
    27     strict->import(@strict); 
    28     warnings->import(@warnings); 
     27sub import { 
     28    shift; 
     29 
     30    my $args = _parse_args(@_); 
     31 
     32    strict->import(@{$args->{strict}}); 
     33    warnings->import(@{$args->{warnings}}); 
    2934} 
    3035 
    3136sub unimport { 
    3237    shift; 
    33     strict->unimport; 
    34     warnings->unimport; 
     38    if (@_) { 
     39        my $args = _parse_args(@_); 
     40 
     41        if (@{$args->{strict}}) { 
     42            strict->unimport(@{$args->{strict}}); 
     43        } 
     44        if (@{$args->{warnings}}) { 
     45            warnings->unimport(@{$args->{warnings}}); 
     46        } 
     47    } 
     48    else { 
     49        strict->unimport; 
     50        warnings->unimport; 
     51    } 
    3552} 
    3653