Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you print hexadecimal digits to a Perl string?

Tags:

string

perl

I have three integers:

($r, $g, $b) = (255, 128, 0);

I would like to print a string like:

"#FF8000"

using those variables.

How do I do this?

like image 874
Frank Krueger Avatar asked Nov 17 '25 21:11

Frank Krueger


1 Answers

my $rgb = sprintf '#%02X%02X%02X', $r, $g, $b;

See sprintf and printf.

like image 140
Sinan Ünür Avatar answered Nov 20 '25 10:11

Sinan Ünür



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!