Perl | oct() Function
oct() function in Perl converts the octal value passed to its respective decimal value. For example, oct(‘1015’) will return ‘525’. This function returns the resultant decimal value in the form of a string which can be used as a number because Perl automatically converts a string to a number in numeric contexts. If the passed parameter is not an octal number then the result will be 0.
Syntax: oct(oct_value)
Parameter:
oct_value: Octal number which is to be converted to decimalReturns:
the octal value converted to decimal value
Example 1:
#!/usr/bin/perl -w # Converting and printing # the decimal value print("oct(31) ", oct('31'), "\n"); print("oct(50) ", oct('50'), "\n"); |
oct(31) 25 oct(50) 40
Example 2:
#!/usr/bin/perl -w # Converting and printing # the decimal value print("oct(106) ", oct('106'), "\n"); print("oct(125) ", oct('125'), "\n"); |
oct(106) 70 oct(125) 85
Recommended Posts:
- Perl | exp Function
- Perl | ord() Function
- Perl | uc() Function
- Perl | hex Function
- Perl | log() Function
- Perl | chr() Function
- Perl | abs() function
- Perl | sin() Function
- Perl | tell() Function
- Perl | each() Function
- Perl | int() function
- Perl | cos() Function
- Perl | chomp() Function
- Perl | srand() Function
- Perl | split() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



