Solved

perl array

Posted on 2000-03-16
7
161 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
Independent Software Vendors: 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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…
Six Sigma Control Plans

696 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