How to Manipulate Array in Perl?
Hi All,
I have one question to ask you about the Perl language. I am getting more difficulties while understanding the Array in Perl. I am not getting how to Manipulate Array in Perl. I have referred different book for this concept without any luck. If anybody of you has the sound knowledge about the array manipulation in Perl then please share your knowledge with me. Your help would appreciable.
Re: How to Manipulate Array in Perl?
In 'Perl' the array manipulation is achieved in very different ways than other languages. See below it's syntax
Quote:
@CombinedArray = (@ArrayName1, @ArrayName2);
The above syntax of Perl is used to combine two array. output of above code will display the combination of all elements of @ArrayName1 as well as @ArrayName2. You can use the below syntax to append the array elements.
Quote:
@MyArrayName = (@MyArrayName, $NewElement);
Re: How to Manipulate Array in Perl?
Hi friend,
I suggest you to refer following example which will depicts how to Manipulate Array in Perl:
Quote:
#! C:\programfiles\perl\bin\perl
print "content-type: text/html\n\n";
@array01 = ("blue", "green");
@array02 = ("red", "white");
@combined = (@array01, @array02);
$, = "\n";
print @combined;
print "<br>";
@new = (@combined,yellow);
$, = "\n";
print @new;
Re: How to Manipulate Array in Perl?
Hi,
Perl programming language is basically designed for to manipulate and read text data. It Perl it is very easy to manipulate the array data because the interpreter of Perl the array data which is based onto contextual data. In Perl the manipulation techniques of array is limited to the elements counting of Perl array or key-value pairs iteration.
Re: How to Manipulate Array in Perl?
In Perl is very simple to build an array of arrays sometime it is referred as list of lists. Suppose you want to declare the array named as @AOP, and which is of [3][2] size. Then you need to implement following code code for this array declaration.
Quote:
@AOP = (
[ "asd", "iok" ],
[ "vbn", "esw", "tgf" ],
[ "uij", "qasw", "nmkl" ],
);
print $AOP[2][2];
bart
Re: How to Manipulate Array in Perl?
Hello friend,
To print the some part of the array in Perl, for this we need to use the subscripting concept of Perl. You can use the pointer arrow for de-referencing the array. suppose you have to print some part of the @AOO array in Perl language, then you need to use the below code:
Quote:
@part1 = ();
$x1 = 4;
for ($y1 = 7; $y1 < 13; $y1++)
{
push @part1, $AOO[$x1][$y1];
}