Scalars
Learn to identify and use Scalars as Perl's fundamental data type. Understand how scalar variables handle different types, how Perl performs value coercion, and how to work with references and boolean contexts. This lesson provides practical insight into Scalars for writing effective Perl code.
Scalars
Perl’s fundamental data type is the scalar: a single, discrete value. That value can be a string, an integer, a floating-point value, a filehandle, or a reference, but it’s always a single value. Scalars may be lexical, package, or global variables. We may declare only lexical or package variables. The names of scalar variables must conform to standard variable-naming guidelines. Scalar variables always use the leading dollar sign $.
Note: Scalar values and scalar context have a deep connection; assigning to a scalar imposes scalar context. Using the scalar sigil with an aggregate variable accesses a single element of the hash or array in the scalar ...