This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
b63d518ee54418a859fa2d93c07c6c7baf544bc2
[perl5.git] / ext / Attribute-Handlers / demo / demo_range.pl
1 package UNIVERSAL;
2 use Attribute::Handlers;
3 use Tie::RangeHash;
4
5 sub Ranged : ATTR(HASH) {
6         my ($package, $symbol, $referent, $attr, $data) = @_;
7         tie %$referent, 'Tie::RangeHash';
8 }
9
10 package main;
11
12 my %next : Ranged;
13
14 $next{'cat,dog'} = "animal";
15 $next{'fish,fowl'} = "meal";
16 $next{'heaven,hell'} = "reward";
17
18 while (<>) {
19         chomp;
20         print $next{$_}||"???", "\n";
21 }