Solved

perl array

Posted on 2000-03-16
7
160 Views
Last Modified: 2010-03-05
i have to add a data to a predefined array but could not be succesfull:
array is;
@data(
[a,b,c,d,e]
[1,2,3,4,5])

i want to add some data to this array but could not be succesfull.
could anyone have any idea?
thanks in advance
0
Comment
Question by:camasuvi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 2

Expert Comment

by:mattrope
ID: 2626060
I think what you're asking is how do you append the contents of one array/list to another...you can do this two ways:

   push(@orig,@extra);
   push(@orig,$extra1,$extra2,$extra3);

or

   @orig = (@orig,@extra);
   @orig = (@orig,$extra1,$extra2);

Hope this is what you were asking for.
0
 
LVL 84

Expert Comment

by:ozo
ID: 2626706
To which of the three arrays in your example do you want to add data, and where in the array do you want to add it?
0
 

Author Comment

by:camasuvi
ID: 2627026
i only want to use that method with gd::graph::lines but push method does not work.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:camasuvi
ID: 2627035
For ozo:
i want to draw a graph and i am using gdgraph.
but my data should be dynamis so i do not know how many data i have.
@data (
   [a,b,c,d]  
   [1,2,3,4])  
a b c and d are x values and 1,2,3,4 are y values. so i want to add (e,5) for example to that array as a new point.
thanks ýn advance
0
 

Author Comment

by:camasuvi
ID: 2627043
For ozo:
i want to draw a graph and i am using gdgraph.
but my data should be dynamis so i do not know how many data i have.
@data (
   [a,b,c,d]  
   [1,2,3,4])  
a b c and d are x values and 1,2,3,4 are y values. so i want to add (e,5) for example to that array as a new point.
thanks ýn advance
0
 
LVL 84

Accepted Solution

by:
ozo earned 40 total points
ID: 2627224
push @{$data[0]},'e';
push @{$data[1]},5;
0
 

Author Comment

by:camasuvi
ID: 2627272
thanks it is vey helpfull for me
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question