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.

Post New Thread Reply

Register GFY Rules Calendar Mark Forums Read
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 09-22-2004, 09:58 PM   #1
archael
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
archael is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-22-2004, 10:17 PM   #2
irishfury
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
irishfury is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-22-2004, 10:21 PM   #3
archael
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
archael is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-22-2004, 10:25 PM   #4
Babaganoosh
♥♥♥ Likes Hugs ♥♥♥
 
Babaganoosh's Avatar
 
Industry Role:
Join Date: Nov 2001
Location: /home
Posts: 15,841
http://www.perldoc.com/perl5.6.1/pod...list-or-array-
__________________
I like pie.
Babaganoosh is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-22-2004, 10:26 PM   #5
irishfury
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
irishfury is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-22-2004, 10:35 PM   #6
archael
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
archael is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-22-2004, 10:35 PM   #7
blackmonsters
Making PHP work
 
blackmonsters's Avatar
 
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!!
blackmonsters is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-22-2004, 10:38 PM   #8
Babaganoosh
♥♥♥ Likes Hugs ♥♥♥
 
Babaganoosh's Avatar
 
Industry Role:
Join Date: Nov 2001
Location: /home
Posts: 15,841
Quote:
Originally posted by archael
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
That's going to be pretty slow...especially if that array gets big. I'd suggest finding another way to do it.
__________________
I like pie.
Babaganoosh is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-22-2004, 10:39 PM   #9
irishfury
Confirmed User
 
Join Date: Aug 2003
Location: In the hearts of cowards
Posts: 2,611
Quote:
Originally posted by Armed & Hammered
That's going to be pretty slow...especially if that array gets big. I'd suggest finding another way to do it.
yup that will be slow...
__________________
Trust no one there all snakes
irishfury is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-22-2004, 10:44 PM   #10
blackmonsters
Making PHP work
 
blackmonsters's Avatar
 
Industry Role:
Join Date: Nov 2002
Location: 🌎🌅🌈🌇
Posts: 20,589
Edit above to this :

push(@mygal, $gals[$c]);
blackmonsters is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-22-2004, 10:46 PM   #11
archael
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?
archael is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-22-2004, 10:46 PM   #12
Babaganoosh
♥♥♥ Likes Hugs ♥♥♥
 
Babaganoosh's Avatar
 
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.
Babaganoosh is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-22-2004, 10:48 PM   #13
archael
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
archael is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-22-2004, 10:55 PM   #14
blackmonsters
Making PHP work
 
blackmonsters's Avatar
 
Industry Role:
Join Date: Nov 2002
Location: 🌎🌅🌈🌇
Posts: 20,589
Quote:
Originally posted by archael
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

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.
blackmonsters is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-22-2004, 10:58 PM   #15
irishfury
Confirmed User
 
Join Date: Aug 2003
Location: In the hearts of cowards
Posts: 2,611
Quote:
Originally posted by blackmonsters
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.
he did say he was just learning
__________________
Trust no one there all snakes
irishfury is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-22-2004, 11:03 PM   #16
blackmonsters
Making PHP work
 
blackmonsters's Avatar
 
Industry Role:
Join Date: Nov 2002
Location: 🌎🌅🌈🌇
Posts: 20,589
Quote:
Originally posted by irishfury
he did say he was just learning
I know. I'm just being a dick because there's no flames on the board right now.
blackmonsters is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-22-2004, 11:06 PM   #17
irishfury
Confirmed User
 
Join Date: Aug 2003
Location: In the hearts of cowards
Posts: 2,611
Quote:
Originally posted by blackmonsters
I know. I'm just being a dick because there's no flames on the board right now.
lol continue on
__________________
Trust no one there all snakes
irishfury is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-22-2004, 11:08 PM   #18
archael
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.
archael is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-22-2004, 11:10 PM   #19
SpikeHeel
Confirmed User
 
Join Date: Oct 2003
Location: Venus
Posts: 1,531
Quote:
Originally posted by blackmonsters
I know. I'm just being a dick because there's no flames on the board right now.
hahaha...i commend you for your initiative to be the flame starter, blackmonsters! way to go!
__________________

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
SpikeHeel is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-22-2004, 11:21 PM   #20
blackmonsters
Making PHP work
 
blackmonsters's Avatar
 
Industry Role:
Join Date: Nov 2002
Location: 🌎🌅🌈🌇
Posts: 20,589
Quote:
Originally posted by archael
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.
Your guru is probably a moron who couldn't pogram a re-dial button on a cellphone.

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.
blackmonsters is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-23-2004, 01:41 AM   #21
irishfury
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
irishfury is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks
Thread Tools



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.