Solved

perl array

Posted on 2000-03-16
7
155 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
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
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…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

914 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

19 Experts available now in Live!

Get 1:1 Help Now