summaryrefslogtreecommitdiff
path: root/dist/Attribute-Handlers/demo/demo_range.pl
blob: b63d518ee54418a859fa2d93c07c6c7baf544bc2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package UNIVERSAL;
use Attribute::Handlers;
use Tie::RangeHash;

sub Ranged : ATTR(HASH) {
	my ($package, $symbol, $referent, $attr, $data) = @_;
	tie %$referent, 'Tie::RangeHash';
}

package main;

my %next : Ranged;

$next{'cat,dog'} = "animal";
$next{'fish,fowl'} = "meal";
$next{'heaven,hell'} = "reward";

while (<>) {
	chomp;
	print $next{$_}||"???", "\n";
}