Scalars
A scalar is a simple data type that is either a number or a character string.
- Numbers are stored as floating point values, even integers.
- Examples of integer literals:
- Examples of float literals:
- 5.67 8456.78 -3.14 3.4e2 4.567e-3 -6.7E27
Strings can be single or double quoted.
- Single quoted strings take all characters literally except \' and \\.
- Double quoted strings include the special meaning of backslashed characters, such as:
- \n newline
- \t tab
- \” quote
- \0 octal
- \x hex
- \c control character
- \u uppercase next character
- \U uppercase until a \E
- \l lowercase the next character
- \L lowercase until a \E
- \E Halt the casing
Operators
- Relational (comparison) for Numbers
- Relational (comparison) for Strings
- String joining (concatenation)
Operators for Numbers
- ++ --
- **
- ! + -
- * / %
- + -
- < > <= >=
- == !=
- &&
- ||
- = += -=
Scalar Variables
- Always have a $ in front, even when assigning a value.
- Names are alphanumeric but must start with a letter.
- A variable in a string is substituted for unless the dollar sign ($) is preceded by a backslash (\) or is between single quotes. Control name length of a variable with curly braces ( { } ).
- See programs under perl/scalars.