package less;
use strict;
use warnings;
our $VERSION = '0.02';
sub _pack_tags {
return join ' ', @_;
}
sub _unpack_tags {
return grep { defined and length }
map { split ' ' }
grep {defined} @_;
}
sub of {
my $class = shift @_;
# If no one wants the result, don't bother computing it.
return unless defined wantarray;
my $hinthash = ( caller 0 )[10];
my %tags;
@tags{ _unpack_tags( $hinthash->{$class} ) } = ();
if (@_) {
exists $tags{$_} and return !!1 for @_;
return;
}
else {
return keys %tags;
}
}
sub import {
my $class = shift @_;
@_ = 'please' if not @_;
my %tags;
@tags{ _unpack_tags( @_, $^H{$class} ) } = ();
$^H{$class} = _pack_tags( keys %tags );
return;
}
sub unimport {
my $class = shift @_;
if (@_) {
my %tags;
@tags{ _unpack_tags( $^H{$class} ) } = ();
delete @tags{ _unpack_tags(@_) };
my $new = _pack_tags( keys %tags );
if ( not length $new ) {
delete $^H{$class};
}
else {
$^H{$class} = $new;
}
}
else {
delete $^H{$class};
}
return;
}
1;
__END__
=head1 NAME
less - perl pragma to request less of something
=head1 SYNOPSIS
use less 'CPU';
=head1 DESCRIPTION
This is a user-pragma. If you're very lucky some code you're using
will know that you asked for less CPU usage or ram or fat or... we
just can't know. Consult your documentation on everything you're
currently using.
For general suggestions, try requesting C