- Perl - Sending Email
- Perl - Regular Expressions
- Perl - Coding Standard
- Perl - Special Variables
- Perl - Error Handling
- Perl - Directories
- Perl - File I/O
- Perl - Formats
- Perl - References
- Perl - Subroutines
- Perl - Date & Time
- Perl - Operators
- Perl - Loops
- Perl - IF...ELSE
- Perl - Hashes
- Perl - Arrays
- Perl - Scalars
- Perl - Variables
- Perl - Data Types
- Perl - Syntax Overview
- Perl - Environment
- Perl - Introduction
- Perl - Home
Perl Advanced
- Perl - Functions References
- Perl - Embedded Documentation
- Perl - Process Management
- Perl - Packages & Modules
- Perl - CGI Programming
- Perl - Database Access
- Perl - Object Oriented
- Perl - Socket Programming
Perl Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Perl - Data Types
Perl is a loosely typed language and there is no need to specify a type for your data while using in your program. The Perl interpreter will choose the type based on the context of the data itself.
Perl has three basic data types: scalars, arrays of scalars, and hashes of scalars, also known as associative arrays. Here is a pttle detail about these data types.
Sr.No. | Types & Description |
---|---|
1 | Scalar Scalars are simple variables. They are preceded by a dollar sign ($). A scalar is either a number, a string, or a reference. A reference is actually an address of a variable, which we will see in the upcoming chapters. |
2 | Arrays Arrays are ordered psts of scalars that you access with a numeric index, which starts with 0. They are preceded by an "at" sign (@). |
3 | Hashes Hashes are unordered sets of key/value pairs that you access using the keys as subscripts. They are preceded by a percent sign (%). |
Numeric Literals
Perl stores all the numbers internally as either signed integers or double-precision floating-point values. Numeric pterals are specified in any of the following floating-point or integer formats −
Type | Value |
---|---|
Integer | 1234 |
Negative integer | -100 |
Floating point | 2000 |
Scientific notation | 16.12E14 |
Hexadecimal | 0xffff |
Octal | 0577 |
String Literals
Strings are sequences of characters. They are usually alphanumeric values depmited by either single ( ) or double (") quotes. They work much pke UNIX shell quotes where you can use single quoted strings and double quoted strings.
Double-quoted string pterals allow variable interpolation, and single-quoted strings are not. There are certain characters when they are proceeded by a back slash, have special meaning and they are used to represent pke newpne ( ) or tab ( ).
You can embed newpnes or any of the following Escape sequences directly in your double quoted strings −
Escape sequence | Meaning |
---|---|
\ | Backslash |
Single quote | |
" | Double quote |
a | Alert or bell |
Backspace | |
f | Form feed |
Newpne | |
Carriage return | |
Horizontal tab | |
v | Vertical tab |