in reply to Getting numeric value of an alphabetic string

You probably want to use a hash for that.

my %color = ( red => 0xFF0000, blue => 0x0000FF, # . . . );
On unix, /usr/X11/lib/X11/rgb.txt is a useful list of standardized named colors with RGB values.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re^2: Getting numeric value of a alphabetic string
by chakkaln (Sexton) on Aug 05, 2005 at 07:04 UTC
    Thanks a lot for the message. Its a bit unclear to me as how can I use this information in my case. I have about 7000 unique identifiers and I need 7000 unique colors for that. Thanks Nagesh
      There are 753 unique colours in the openwin rgb.txt on the machine nearest my thumb and the following code indexes them by unique name into a hash of hash :
      #!/usr/bin/perl use Data::Dumper; open RGB, '</usr/openwin/lib/rgb.txt'; my %rgb = (); while ( <RGB> ) { if ( /^(\d+)\s*(\d+)\s*(\d+)\s*(.*)$/ ) { $rgb{ $4 }{ red } = $1; $rgb{ $4 }{ green } = $2; $rgb{ $4 }{ blue } = $3; } } print Dumper( \%rgb );
      output: