From the course: Perl 5 Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Understanding values and variables

Understanding values and variables - Perl Tutorial

From the course: Perl 5 Essential Training

Start my 1-month free trial

Understanding values and variables

- [Voiceover] In Perl, a variable contains one or more values. A value is a unit of data. It may be numeric, textural, or logical. A variable is simply a named container for one or more values. Perl doesn't use types in the same way that some other languages use types. To distinguish between integers, floats, and text, Perl uses context to determine type. This is a system called Duck Typing. In other words, if it quacks like a duck, it must be a duck. So if a value is used as a number, Perl will treat it as a number. If it's used as a string, Perl will treat it as a string. This actually works surprisingly well and for most purposes, you'll never need anything more sophisticated. A variable name may consist of any combination of characters but it's generally considered good practice to restrict your variable names to the set of lowercase and uppercase Roman letters, the 10 ASCII decimal digits and the underscore symbol. Perl provides three basic storage types. A scalar holds a single…

Contents