Perl Language: How To Use Arrays in Perl Program

in #perl5 years ago

Learn How To Use Arrays in Perl Program. Most of the languages have their own ways to handle the arrays. And here the perl is no different. Perl to has it's own ways to manage the arrays. So here the below video shows you how to make use of an array in perl language. So check out the video and let me know if you understand the example in the below comment section.

If you like this video then Do share the video in the article to your friends or in your social media accounts. You can also subscribe to the youtube channel.

I recommend checking out Learning Perl book. You can get a lot of answers to your questions. Plus the new edition of the book can cover some of the latest topics too.

What are arrays?

So now that you have seen the array example in the video. Let's see the arrays in short.

  1. Arrays are basically ordered list of the content.
  2. Arrays in perl start with the @ symbol.
  3. You can use the $ sign and the index number to point to the array element.

Here's the syntax for the perl's arrays. You can take a look at the code snippet below.

@array  =  (1,  2, 3);

Here you can see the array has the integer elements in it. And you can access each element using the $ symbol. Like the example below.

$array[0]

Now you get the idea of how to create an array in perl. And also learned how to make use of the array element and display it on the console. It starts from zero and it should increment further from there.

I hope that this tutorial article helped.

If you haven't checked out the first video in the series. Check how to run program in Perl .

Also do check out the second video on the Variables in Perl language.

Tips for Running Perl Code

You can check the installation of the perl by typing the following code if you are on unix or linux, in case of windows you have to check the path if perl bin folder is added there.

which perl

Perl code requires you to have the code stored in the .perl file extension file. This way when you run the perl code say it's in the file named helloworld . pl

You can run the perl file on command prompt like this.

perl helloworld . pl

That's it. You can now execute the perl code on your computer.

If you are interested in modern language, try Go Language Tutorials.

I hope the information here helps you. I'd appreciate if you like the video and share it with others.

Coin Marketplace

STEEM 0.29
TRX 0.12
JST 0.033
BTC 63457.41
ETH 3119.12
USDT 1.00
SBD 3.94