How to create Array in Perl?

PERLServer Side ProgrammingProgramming Scripts

<p>Perl Array variables are prefixed with the @ sign and are populated using either parentheses or the qw operator. For example &minus;</p><pre class="result notranslate">@array = (1, 2, &#39;Hello&#39;); @array = qw/This is an array/;</pre><p>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 &#39;this&#39; and last (fourth) is &#39;array&#39;. This means that you can use different lines as follows &minus;</p><pre class="result notranslate">@days = qw/Monday Tuesday ... Sunday/;</pre><p>You can also populate an array by assigning each value individually as follows &minus;</p><pre class="result notranslate">$array[0] = &#39;Monday&#39;; ... $array[6] = &#39;Sunday&#39;;</pre>
raja
Updated on 28-Nov-2019 09:34:35

Advertisements