eWebProgrammer
Distributednetworks GofPatterns
prev next prev next
  Course navigation
 
Lesson 5
Objective
Numeric Strings and Literals in Perl
Examine how numeric and string literals are specified.
   
In programmer-speak, literals are values that are entered in the source code explicitly.
For example, in the expression $x = 5 the number 5 is a literal.
There are two types of literals to consider:
  1. Perl Numeric Literals
  2. Perl String Literals
Numeric literals are frequently used and represent a number that your program will need to work with.
Most of the time you will use numbers in ten-base expression.
Perl will also let you use base 8 (octal) or base 16 (hexadecimal).
  1. In octal notation or base eight, when you see the value 15 it signifies (1 * 8) + 5 or 1310.
  2. In hexadecimal notation when you see the value 15 it signifies (1 * 16) + 5 or 2110.
    Base 16 needs an additional 6 characters besides the digits 0 to 9 so that each position can have a total of 16 values.
    The letters A-F are used to represent 11-16.
So the value BD16 is equal to (B16 * 16) * D16 or (1110 * 16) + 1310 which is 17610.
  Course navigation