Solved

perl array

Posted on 2000-03-16
7
157 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

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…
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…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

770 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