spewn
Programmer
- May 7, 2001
- 1,034
i have an array of sorts:
$listarray='4857|4/8/2009,9568|4/9/2009,2368|4/10/2009,3746|4/12/2009,4987|4/15/2009,7283|4/16/2009,7428|4/18/2009,4993|4/19/2009,9968|4/19/2009,9968|4/19/2009,9968|4/19/2009';
i'm trying to see if a certain element is repeated in $listarray, as i'm cycling through each element in the array.
i have this:
this works if it's repeated, but since i want to know how many times it appears, since it will always be true because it i counting itself.
for instance, the string '9968|4/19/2009' appears 3 times, and i need to know that it appears 2 extra times.
any ideas?
thanks!
- g
$listarray='4857|4/8/2009,9568|4/9/2009,2368|4/10/2009,3746|4/12/2009,4987|4/15/2009,7283|4/16/2009,7428|4/18/2009,4993|4/19/2009,9968|4/19/2009,9968|4/19/2009,9968|4/19/2009';
i'm trying to see if a certain element is repeated in $listarray, as i'm cycling through each element in the array.
i have this:
Code:
dupe=0;
@lagroup=split(/,/,$listarray);
foreach $lag (@lagroup) {
if ($listarray =~ /$lag/) {$dupe++;}
}
this works if it's repeated, but since i want to know how many times it appears, since it will always be true because it i counting itself.
for instance, the string '9968|4/19/2009' appears 3 times, and i need to know that it appears 2 extra times.
any ideas?
thanks!
- g