473,386 Members | 1,773 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How can I save the elements in array, and compare with a new one?

76
Hi,
Can anyone please tell me how can I save the elements in one array (@temp) while the other one (@pdb) changes every time I execute the script.
Thanks a lot in advance.

Following is what I got so far:

Expand|Select|Wrap|Line Numbers
  1. @pdb =('XYZAC','ABCXZ','QQWWA');  #this one changes 
  2. @temp=@pdb;     # @temp should get the elements of the previous @pdb
  3.  
  4. my %pdb=map{$_ =>1} @pdb;
  5. my %temp=map{$_=>1} @temp;
  6.  
  7. my @diff_once = grep(!defined $pdb{$_}, @temp);
  8. print "the differences are:\t$_\n" foreach (@diff_once);
  9.  
  10.  
Dec 12 '07 #1
2 1087
KevinADC
4,059 Expert 2GB
Look into the Storable module, it comes with perl. Or write the array to a file and read it back in from a file each time the code reruns.
Dec 13 '07 #2
idorjee
76
thanks for your reply, KevinADC
Dec 13 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

18
by: deko | last post by:
I have a counter file that records page hits - each hit is a UNIX timestamp in the file. But I'm only interested in page hits in the last 365 days. The below code creates an array from the file...
9
by: Varun Sinha | last post by:
I have an array of chars. I want to loop through it, compare each element to different chars and depending on which character it matches, take some action. My problem is that I can't figure out...
3
by: Stefano | last post by:
I've a form windows with a lot of textbox controls. How can I do if I have to save all text proprety of this controls in an external file, to reload them in future?
4
by: Tad Marshall | last post by:
Hi, I'm reading about arrays in VB.NET and I seem to have a few options for my data structure. I need a multi-dimensional array of structures, and my first thought was Public Structure myStr...
8
by: david.lindsay.green | last post by:
Hello all, I am quite new a web scripting and making web pages in general and I have stumbled across a problem I have as yet been unable to solve. I am trying to take the contents of a textarea box...
1
by: wartech | last post by:
Hey everyone, My objective here is to be able to sort the array that i created from a structure. When I attempt to do this I get a message stating "Failed to compare two elements in the array". ...
4
by: vaiism | last post by:
I am trying to write a string compare function using pointers and dynamic arrays, and am having trouble comparing the individual elements of the array contained with the struct. The code below...
4
by: aarthi28 | last post by:
Hi, I am trying to compare 2 vectors of different sizes, and if the same element exists in both, I want to replace them by the text "aa". I thought this would work, but it replaces the entire...
16
by: sophia.agnes | last post by:
Hi, is there any guarantee that elements of an un initialized array by default contains the element 0 ?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.