| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Acme::AutoColor; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 3 |  |  | 3 |  | 10659 | use 5.006; | 
|  | 3 |  |  |  |  | 14 |  | 
|  | 3 |  |  |  |  | 127 |  | 
| 4 | 3 |  |  | 3 |  | 18 | use strict; | 
|  | 3 |  |  |  |  | 5 |  | 
|  | 3 |  |  |  |  | 139 |  | 
| 5 | 3 |  |  | 3 |  | 31 | use warnings; | 
|  | 3 |  |  |  |  | 7 |  | 
|  | 3 |  |  |  |  | 140 |  | 
| 6 |  |  |  |  |  |  |  | 
| 7 | 3 |  |  | 3 |  | 3130 | use Graphics::ColorNames 0.32; | 
|  | 3 |  |  |  |  | 27643 |  | 
|  | 3 |  |  |  |  | 442 |  | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | our $VERSION = '0.03'; | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | our $Colors; | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | sub import { | 
| 14 | 2 |  |  | 2 |  | 19 | my $class = shift; | 
| 15 |  |  |  |  |  |  | # TODO: parse version numbers | 
| 16 | 2 |  |  |  |  | 10 | $Colors = Graphics::ColorNames->new(@_); | 
| 17 |  |  |  |  |  |  | } | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | package main; | 
| 20 |  |  |  |  |  |  |  | 
| 21 | 3 |  |  | 3 |  | 36 | use Carp qw( croak ); | 
|  | 3 |  |  |  |  | 7 |  | 
|  | 3 |  |  |  |  | 154 |  | 
| 22 | 3 |  |  | 3 |  | 15 | use Graphics::ColorNames qw( hex2tuple ); | 
|  | 3 |  |  |  |  | 9 |  | 
|  | 3 |  |  |  |  | 544 |  | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  | our $AUTOLOAD; | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | sub AUTOLOAD { | 
| 27 | 7 |  |  | 7 |  | 33647 | my $class = shift; | 
| 28 | 7 |  |  |  |  | 31 | $AUTOLOAD =~ /.*::(\w+)/; | 
| 29 |  |  |  |  |  |  |  | 
| 30 | 7 |  |  |  |  | 16 | my $cname = $1; | 
| 31 |  |  |  |  |  |  |  | 
| 32 | 7 | 100 |  |  |  | 23 | if($cname eq "OCTARINE") { | 
| 33 |  |  |  |  |  |  | # Discworlds eigth color. Can't display it yet, | 
| 34 |  |  |  |  |  |  | # but as far as we know, R, G and B are zero, | 
| 35 |  |  |  |  |  |  | # and O is 255 | 
| 36 | 2 | 100 |  |  |  | 7 | if(wantarray) { | 
| 37 | 1 |  |  |  |  | 4 | return(0,0,0,255); | 
| 38 |  |  |  |  |  |  | } else { | 
| 39 | 1 |  |  |  |  | 7 | return "000000ff"; | 
| 40 |  |  |  |  |  |  | } | 
| 41 |  |  |  |  |  |  | } | 
| 42 |  |  |  |  |  |  |  | 
| 43 | 5 |  |  |  |  | 14 | my $value = $Acme::AutoColor::Colors->FETCH($1); | 
| 44 | 5 | 100 |  |  |  | 94 | if (defined $value) { | 
| 45 | 4 | 100 |  |  |  | 22 | return wantarray ? hex2tuple($value) : $value; | 
| 46 |  |  |  |  |  |  | } else { | 
| 47 | 1 |  |  |  |  | 275 | croak "Unknown method: $cname"; | 
| 48 |  |  |  |  |  |  | } | 
| 49 |  |  |  |  |  |  | } | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | 1; | 
| 52 |  |  |  |  |  |  | __END__ |