#!/usr/bin/perl use strict; use warnings; no warnings 'qw'; use Graphics::ColorNames 'hex2tuple'; tie my %colors, 'Graphics::ColorNames', 'WWW'; for my $color (qw(lightgreen #ff0000 grey #123456 #foobar blue unknown)) { if ( defined $colors{$color} ) { my @rgb = hex2tuple $colors{$color}; print "$color => @rgb\n"; } else { print "unknown color '$color'\n" } } # for