Perl oct Function

Advertisements


Description

This function converts EXPR from octal to decimal. For example, oct('0760') will return '496'. You can use the string returned as a number because Perl will automatically convert strings to numbers in numeric contexts. Passed parameter should be an octal number otherwise it will produce zero as a result.

Syntax

Following is the simple syntax for this function:

oct EXPR

oct

Return Value

This function returns the decimal value.

Example

Following is the example code showing its basic usage:

#!/usr/bin/perl -w

print("oct(88) ", oct('88'), "\n");
print("oct(0760) ", oct('0760'), "\n");

When above code is executed, it produced following result




Advertisements
Advertisements