- Perl Basics
- Perl Home
- Perl Basic Syntax
- Perl Data Types
- Perl Variables
- Perl Scalars
- Perl Arrays
- Perl Hashes
- Perl If-Else
- Perl Loops
- Perl Operators
- Perl References
- Perl Subroutines
- Perl Formats
- Perl Date & Time
- Perl File I/O
- Perl Advanced
- Perl Directory
- Perl Regular Expressions
- Perl Special Variables
- Perl Socket Programming
- Perl Send E-mail
- Perl Object Oriented
- Perl Error Handling
- Perl CGI Programming
- Perl Database
- Perl Packages & Modules
- Perl Process Management
- Perl Test
- Perl Online Test
- Give Online Test
- All Test List
Perl Data Types
There is no any need to specify a type for your data in a Perl program. There are following basic data types available in perl:
- scalars
- hashes
- arrays
Scalars in Perl
Scalars in perl are simple variables, are preceded by a dollar ($) sign. A scalar in perl is either a number, a string, or a reference. Here are some examples of scalars in perl:
$first_name = "codes"; $last_name = "cracker";
Hashes in Perl
Hashes in perl are unordered sets of key/value pairs, you access using the keys are subscripts. Hashes in perl are preceded by a percent (%) sign. Here are some examples of hashes in perl:
%marks = ("first" => 100, "second" => 99, "third" => 98); %roll = ("Devraj" => 15, "Vinay" => 46, "Ashwani" => 10);
Arrays in Perl
Arrays in perl are ordered list of scalars, you access with a numeric index, starts from 0. Arrays in perl are preceded by an at (@) sign. Here are some examples of arrays in perl:
@marks = (100, 99, 98); @names = ("Devraj", "Vinary", "Ashwani");
« Previous Tutorial Next Tutorial »