![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Registered User
Join Date: Jun 2003
Posts: 51
|
Little perl problem, help needed
im just trying to erase duplicates entries .. here's what i got:
basically, i search my database for my own stuff first and its put in @gals2. Now im searching @gals2 for the current result ($_) and if its a match, then current result is replaced by $nothing which is $nothing = ""; while(my @gals = $sth->fetchrow) { if (@gals2 =~ /$_/){ $_ = $nothing; } its not displaying any change at all in my results.. it's as if that whole code didn't exist. Any input will be appreciated, Jon |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Confirmed User
Join Date: Aug 2003
Location: In the hearts of cowards
Posts: 2,611
|
trying to remove it from the array?
__________________
Trust no one there all snakes |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
Registered User
Join Date: Jun 2003
Posts: 51
|
yeah if the current result matches anything in the first array, i want it to be remove from the current one
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 |
♥♥♥ Likes Hugs ♥♥♥
Industry Role:
Join Date: Nov 2001
Location: /home
Posts: 15,841
|
__________________
I like pie. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
Confirmed User
Join Date: Aug 2003
Location: In the hearts of cowards
Posts: 2,611
|
a) If @in is sorted, and you want @out to be sorted: (this assumes all true values in the array)
$prev = 'nonesuch'; @out = grep($_ ne $prev && ($prev = $_), @in); This is nice in that it doesn't use much extra memory, simulating uniq(1)'s behavior of removing only adjacent duplicates. It's less nice in that it won't work with false values like undef, 0, or ``''; ``0 but true'' is ok, though. b) If you don't know whether @in is sorted: undef %saw; @out = grep(!$saw{$_}++, @in); c) Like (b), but @in contains only small integers: @out = grep(!$saw[$_]++, @in); d) A way to do (b) without any loops or greps: undef %saw; @saw{@in} = (); @out = sort keys %saw; # remove sort if undesired e) Like (d), but @in contains only small positive integers: undef @ary; @ary[@in] = @in; @out = @ary;
__________________
Trust no one there all snakes |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 |
Registered User
Join Date: Jun 2003
Posts: 51
|
i had come across that one but it wont work with my method of displaying results.
First, i display my own results first, then all the rest. My own results are in an array and the second one, in another array. I need to do it exactly as it happens. In the while loop, i need every $_ to check if its present in the first array. If its present, i need $_ to skip to the next result |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 |
Making PHP work
Industry Role:
Join Date: Nov 2002
Location: 🌎🌅🌈🌇
Posts: 20,589
|
@gals = sort @gals;
$c=0; foreach(@gals) { if ($gals[$c] eq $gals[$c+1]) { $nothing=$youstupid; } else { push(@mygal, $gals); } $c++; } Try that you dumbasses!! |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#8 | |
♥♥♥ Likes Hugs ♥♥♥
Industry Role:
Join Date: Nov 2001
Location: /home
Posts: 15,841
|
Quote:
__________________
I like pie. |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#9 | |
Confirmed User
Join Date: Aug 2003
Location: In the hearts of cowards
Posts: 2,611
|
Quote:
__________________
Trust no one there all snakes |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#10 |
Making PHP work
Industry Role:
Join Date: Nov 2002
Location: 🌎🌅🌈🌇
Posts: 20,589
|
Edit above to this :
push(@mygal, $gals[$c]); |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#11 |
Registered User
Join Date: Jun 2003
Posts: 51
|
Hmmm is there any faster way of doing it?
i think there's something wrong with if(@gals =~ /$_/) am i using the right method to search an array or is that method only used to search strings? |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#12 |
♥♥♥ Likes Hugs ♥♥♥
Industry Role:
Join Date: Nov 2001
Location: /home
Posts: 15,841
|
You really should get the results in one query if at all possible. I tried to help you in the other thread but without seeing the structure of the DB I really can't even begin to guess how your system is laid out. If you'd post your db structure and some sample data we can figure something out.
__________________
I like pie. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#13 |
Registered User
Join Date: Jun 2003
Posts: 51
|
im not that good in perl, im still learning, but i think the code above will remove duplicate entries next to each other in the results list. That is barely ever the case. Which is why i need it to check everytime its a new $_ if its in the first array. If it is, it needs to be skipped
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#14 | |
Making PHP work
Industry Role:
Join Date: Nov 2002
Location: 🌎🌅🌈🌇
Posts: 20,589
|
Quote:
Duh, why don't you put all the shit in an array and sort it; which makes the duplicates next to each other!!! Damn; I didn't think I needed to explain that. |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#15 | |
Confirmed User
Join Date: Aug 2003
Location: In the hearts of cowards
Posts: 2,611
|
Quote:
![]()
__________________
Trust no one there all snakes |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#16 | |
Making PHP work
Industry Role:
Join Date: Nov 2002
Location: 🌎🌅🌈🌇
Posts: 20,589
|
Quote:
![]() |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#17 | |
Confirmed User
Join Date: Aug 2003
Location: In the hearts of cowards
Posts: 2,611
|
Quote:
![]()
__________________
Trust no one there all snakes |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#18 |
Registered User
Join Date: Jun 2003
Posts: 51
|
i cant sort it because it has to be done on-the-fly.
i tried doing that before but there was a huge problem with foreach which was displaying everything wrong. Even a guru coder had trouble finding the problem there. It just didn't work. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#19 | |
Confirmed User
Join Date: Oct 2003
Location: Venus
Posts: 1,531
|
Quote:
![]()
__________________
![]() 100% exclusive fetish content - 60% recurring CCBill program No pop-ups – No traffic leaks – No cross sells – Hosted galleries – Promo content - Free Hosting - ICQ: 228585136 |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#20 | |
Making PHP work
Industry Role:
Join Date: Nov 2002
Location: 🌎🌅🌈🌇
Posts: 20,589
|
Quote:
Now you say the "Foreach" verb is broken! More like your guru didn't add the "$c++;" to the loop and guess what happens...it dislplays eveything wrong. |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#21 |
Confirmed User
Join Date: Aug 2003
Location: In the hearts of cowards
Posts: 2,611
|
sorry bro didn't see ya icq I'm passing out if ya still need help hit me tommorrow
__________________
Trust no one there all snakes |
![]() |
![]() ![]() ![]() ![]() ![]() |