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.
Number | Type of Literal |
---|---|
6 | An integer |
12.5 | A floating point number |
15. | Another floating point number |
.7320508 | Yet another floating-point number |
1e10 | Scientific notation |
6.67E - 33 | Scientific notation (e or E is acceptable) |
4_294_296 | A large number with underscores instead of commas |
Numbers are expressed as you think they would be. Integers are just groups of consecutive digits. Floating-point decimal numbers contain a decimal point in the correct ...
Get SAMS Teach Yourself Perl in 24 Hours THIRD EDITION 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.