What is the new octal syntax in Perl 5.3.4?

Perl is a widely used general-purpose programming language. It offers great services, including text manipulation, GUI development, and much more.

There were many enhancements from the Perl 5.32.0 release and the 5.34.0 release. Click here for a full list of differences between the two versions.

In this shot, let’s talk about the new octal syntax in Perl 5.34.0.

New octal syntax

The update to v5.34.0 introduces a new way to specify octalOctal is a base-8 number system using digits 0 to 7. values. In the new version, it is now possible to declare octal numbers using 0o as a prefix. For example, 0o1236 is an octal number in Perl.

We can use the built in method oct() to convert octal values to corresponding decimal values. This oct() also accepts the octal parameter using this new octal syntax.

Previously, octal numbers were declared as follows:

0466 (Numbers that begin with 0).

Alternatively, in this new method, the numbers can be initialized as 0o1236 using the 0o prefix.

Copyright ©2024 Educative, Inc. All rights reserved