Using sprintf.
#!/usr/local/bin/perl $num = 26; $outstr = sprintf("%d = %x hexadecimal or %o octal\n", $num, $num, $num); print ($outstr);