PERL Tutorial Example: binary hexadecimal octal to decimal conversion in perl

PERL Tutorial Example: binary hexadecimal octal to decimal conversion in perl

create a file named "perl-tutorial-example-binary-octal-hexadecimal-decimal.pl" then copy and paste the below code:

$DecimalNumber   = 999;
$BinaryNumber   = 0b1111100111; # adding 0b before a Binary number will convert it to Decimal
$HexadecimalNumber = 0x3E7; # adding 0x before an Hexadecimal number will convert it to Decimal
$OctalNumber   = 01747; # adding 0 before an Octal number will convert it to Decimal

print "\n\n";

print "Binary, Hexadecimal, Octal To Decimal Number Conversion :\n\n";

print "Decimal Number = $DecimalNumber\n";
print "Binary Number Converted to $BinaryNumber\n";
print "Hexadecimal Number Converted to $HexadecimalNumber\n";
print "Octal Number Converted to $OctalNumber\n";

PERL Example Base Tutorial: binary hexadecimal octal to decimal conversion in perl

Now run the program (perl-tutorial-example-binary-octal-hexadecimal-decimal.pl) from command prompt & get results as follows:

PERL Tutorial Example: binary hexadecimal octal to decimal conversion in perl - output in the windows command prompt

The result in the windows command prompt

No comments:

Post a Comment

leave your comments here..