It'd be very neat if you separated your code and placed it within the special "<code>" and "</code>" tags.

"Do we need to declare array elemnts in double quotes"

@array1 = ('one','two','three'); @array2 = ("four","five","six"); print "@array1\n@array2"; #OUTPUT one two three four five six
You can use Perl's quote like operators instead if you did not want to use quotes, however, using single quotes and double quotes can be critical when you want to interpolate ...consider the following quick example and see the differences in the output...
@array = qw(one two three); print @array, "\n"; print "@array\n"; print '@array\n'; __END__ onetwothree #array elements are fused. one two three #spaced and the "\n" replaced with a new line. @array\n #prints @array and "\n" as literals.
Let's expand on... Guess what the outcome of the code below is, as an exercise :
use strict; #a good habit to start your program with line use warnings; #another good habit too... my @array1 = ("one", "two", "five"); my @array2 = ("three","four"); my @array3 = ("one","two",@array2,"five"); my @array4 = ("one","two",'@array2',"five"); my @array5 = ("one","two","@array2","five"); print "@array3\n"; print "@array4\n"; print "@array5\n";

You can loop through your array with a for loop iteration too and using an incremented index allows you to access array elements in turns.

@array = qw(one two three four); for($index=0;$index<=$#array;$index++){ print $array[$index],"\n"; }
Read more at for loops and foreach loops, other than that, you can try and see for yourself if something really works and observe the behavior differences by experimenting on your options, this can let you discover new things as well as solidify your knowledge of something you learnt..

Update: Added examples...


Excellence is an Endeavor of Persistence. Chance Favors a Prepared Mind.

In reply to Re: looping through array by biohisham
in thread looping through array by manishrathi

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.