Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

Share this Page URL

Values and Expressions > Multiline Strings - Pg. 60

Those figures are supposed to be in the trillions, but it's very hard to tell if they have the right number of zeros. So Perl provides a convenient mechanism for making large numbers easier to read: you can use underscores to "separate your thousands": # In the US they use $US_GDP $US_govt_revenue $US_govt_expenditure thousands, millions, billions, trillions, etc... = 10_990_000_000_000; = 1_782_000_000_000; = 2_156_000_000_000; Prior to Perl 5.8, these separators could only be placed in front of every third digit of an integer (i.e., to separate the thousands, millions, billions, etc.). From 5.8 onwards, underscores can be placed between any two digits. For example: # In India they use lakhs, crores, arabs, kharabs, etc... $India_GDP = 30_33_00_00_00_000; $India_govt_revenue = 86_69_00_00_000; $India_govt_expenditure = 1_14_60_00_00_000; Separators can also now be used in floating-point numbers and non-decimals, to make them easier to comprehend as well: use bignum; $PI = 3.141592_653589_793238_462643_383279_502884_197169_399375; $subnet_mask= 0xFF_FF_FF_80; Multiline Strings