Literals

Perl has two different types of scalar constants called literals: numeric literals and string literals.

Numbers

Numeric literals are numbers, and Perl accepts several different ways of writing numbers. All the examples shown in Table 2.1 are valid numeric literals in Perl.

Table 2.1. Samples of Numeric Literals
NumberType of Literal
6An integer
12.5A floating point number
15.Another floating point number
.7320508Yet another floating-point number
1e10Scientific notation
6.67E-33Scientific notation (e or E is acceptable)
4_294_296A large number with underscores instead of commas

Numbers are expressed as you think they would be. Integers are just consecutive digits. For floating point (decimal) numbers, you use a decimal point where you normally ...

Get Sams Teach Yourself Perl in 24 Hours now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.