Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



How to Manipulate Array in Perl?

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 20-01-2010
Member
 
Join Date: Dec 2009
Posts: 38
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.

Reply With Quote
  #2  
Old 20-01-2010
Member
 
Join Date: May 2008
Posts: 2,290
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);
Reply With Quote
  #3  
Old 20-01-2010
Member
 
Join Date: Oct 2005
Posts: 2,389
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;
Reply With Quote
  #4  
Old 20-01-2010
Member
 
Join Date: May 2008
Posts: 2,381
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.
Reply With Quote
  #5  
Old 20-01-2010
Member
 
Join Date: Feb 2008
Posts: 1,845
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
Reply With Quote
  #6  
Old 20-01-2010
Member
 
Join Date: Jan 2008
Posts: 1,514
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];
}
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to Manipulate Array in Perl?"
Thread Thread Starter Forum Replies Last Post
How to manipulate an ISO images Zeppelin Operating Systems 4 31-12-2010 12:44 AM
How to manipulate text in Authorware Lawford Windows Software 5 16-03-2010 02:21 AM
How to Manipulate DOM of Applet's Web Page? shivendra Software Development 5 18-02-2010 12:53 AM
How to manipulate JavaScript text? Juaquine Software Development 4 11-02-2010 04:46 PM
Manipulate jQuery with PHP Zecho Software Development 5 16-06-2009 02:14 AM


All times are GMT +5.5. The time now is 07:50 PM.