Results 1 to 8 of 8
Is there anyway to compare elements of same array or any other way??
Please suggest?...
- 03-24-2008 #1Linux Newbie
- Join Date
- Jan 2008
- Posts
- 114
How can I compare elements of Same Array?
Is there anyway to compare elements of same array or any other way??
Please suggest?Switched to Scripting
- 03-24-2008 #2Just Joined!
- Join Date
- Oct 2007
- Posts
- 9
use strstr();
strstr
- 03-25-2008 #3Linux Newbie
- Join Date
- Jan 2008
- Posts
- 114
Sorry I did not get you.. is this a perl module...do I need to install it ?
Switched to Scripting
- 03-26-2008 #4Linux User
- Join Date
- Jan 2007
- Location
- cleveland
- Posts
- 452
please help us to understand your problem:
suppose a, b and c are numbers, and {a,b,c} is an array.
are you trying to compare a (first element) with b (second element)
or what?the sun is new every day (heraclitus)
- 03-26-2008 #5Linux Newbie
- Join Date
- Jan 2008
- Posts
- 114
Ok, what I am doing I am pushing the values in an array at runtime but before pushing the value I want to check whether it is already there in array or not. If it is already there then count is another variable which be will increased automatically and later I'll join the matched array element + count somehow.
example @arr = ("192.168.1.0","192.168.2.0","192.168.3.0");
want to check if
$chk = "192.168.2.0";
is already then it will become (element + count)
$count =1;
@ant = "192.168.2(2)";Switched to Scripting
- 03-26-2008 #6Linux User
- Join Date
- Aug 2006
- Posts
- 458
i would suggest using a hash instead.
- 03-26-2008 #7Linux Newbie
- Join Date
- Jan 2008
- Posts
- 114
Could you please suggest some example?
Switched to Scripting
- 03-26-2008 #8Linux User
- Join Date
- Aug 2006
- Posts
- 458
perldoc -q hash
look for "How can I get the unique keys from two hashes?"
you can see how the hash value is incremented. That should be your count.


Reply With Quote