Solved

perl array

Posted on 2000-03-16
7
154 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
  • 4
  • 2
7 Comments
 
LVL 2

Expert Comment

by:mattrope
Comment Utility
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
Comment Utility
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
Comment Utility
i only want to use that method with gd::graph::lines but push method does not work.
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:camasuvi
Comment Utility
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
Comment Utility
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
Comment Utility
push @{$data[0]},'e';
push @{$data[1]},5;
0
 

Author Comment

by:camasuvi
Comment Utility
thanks it is vey helpfull for me
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now