
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Create Array in Perl
Perl Array variables are prefixed with the @ sign and are populated using either parentheses or the qw operator. For example −
@array = (1, 2, 'Hello'); @array = qw/This is an array/;
The second line uses the qw// operator, which returns a list of strings, separating the delimited string by white space. In this example, this leads to a four-element array; the first element is 'this' and last (fourth) is 'array'. This means that you can use different lines as follows −
@days = qw/Monday Tuesday ... Sunday/;
You can also populate an array by assigning each value individually as follows −
$array[0] = 'Monday'; ... $array[6] = 'Sunday';
Advertisements