Hi there,
I am trying to create a function that converts rgb values to html hex color code.
The function prints the color codes correctly to the screen, but what I need to do is to have this function return the string instead of printing it.
Currently, it doesn't return the correct html value (but prints the value correctly to screen).
I am guessing that's something to do with the printf function. Is there anyway I can have this hex code returned as a string variable that having it print to the screen instead?
I am trying to create a function that converts rgb values to html hex color code.
The function prints the color codes correctly to the screen, but what I need to do is to have this function return the string instead of printing it.
Code:
sub rgbToHex {
$red=$_[0];
$green=$_[1];
$blue=$_[2];
printf (" #%2.2X%2.2X%2.2X\n",$red,$green,$blue);
return (" #%2.2X%2.2X%2.2X\n",$red,$green,$blue)
}
Currently, it doesn't return the correct html value (but prints the value correctly to screen).
I am guessing that's something to do with the printf function. Is there anyway I can have this hex code returned as a string variable that having it print to the screen instead?