PERL Help

Ok I made this PERL script and it was working flawlessly, untill today, of course near the time I was about to start using it. It's for a LAN Party registration and I made an array and told it to look through the array and if a predefined variable equals an array value then set another variable equal to < font c ...

Slack Space 1613 This topic was started by ,


data/avatar/default/avatar15.webp

143 Posts
Location -
Joined 2000-04-18
Ok I made this PERL script and it was working flawlessly, untill today, of course near the time I was about to start using it. It's for a LAN Party registration and I made an array and told it to look through the array and if a predefined variable equals an array value then set another variable equal to < font color = ' gold ' > $alias. Well it worked but now isn't....everything else is working though. Here's the array part.
 
 
@specialpeeps = ("O.A.P.", "Blakflagg", "O.T.A.", "Smokin_Gunz", "Godiwill", "Pittdog", "ReggieReg", "Prophet", "Rapture", "Knight", "Antimatter", "shr1nk", "Ronin", "aeflux", "Apollo", "Mindphlux", "Renderer", "Paradox", "StevenKao", "Meadeiac", "Net$ushi", "GodCani", "The_Milkman", "RogueDawg", "Girl Injector", "nicad", "Oz|zY");
 
foreach $i (@specialpeeps) {
 
if ($alias eq "$i")
{
$name = "< font color = '#CCCC33' > $alias";
}else {
 
$name = "< font color = ' white' >$alias";
 
}
}
 
I can post the whole script if need be. This is really bothering me. It seems as if it just isn't parsing the array.

Participate on our website and join the conversation

You have already an account on our website? Use the link below to login.
Login
Create a new user account. Registration is free and takes only a few seconds.
Register
This topic is archived. New comments cannot be posted and votes cannot be cast.

Responses to this topic


Administrator

data/avatar/0/0b385d2cbb4fcc3a67cc1faf071a808432c41071.jpg

1795 Posts
Location -
Joined 1999-07-15
Here the fix
 
@specialpeeps = ("O.A.P.", "Blakflagg", "O.T.A.", "Smokin_Gunz", "Godiwill", "Pittdog", "ReggieReg", "Prophet", "Rapture", "Knight", "Antimatter", "shr1nk", "Ronin", "aeflux", "Apollo", "Mindphlux", "Renderer", "Paradox", "StevenKao", "Meadeiac", "Net$ushi", "GodCani", "The_Milkman", "RogueDawg", "Girl Injector", "nicad", "Oz|zY");
 
$found = "No";
 
foreach $i (@specialpeeps) {
 
if ($found eq "No") {
if ($alias eq "$i")
{
$name = " $alias";
$found = "Yes";
}else {
 
$name = "$alias";
 
}
}
}

data/avatar/default/avatar27.webp

1117 Posts
Location -
Joined 2000-01-23
don't know if you care, but here's an explanation of your problem:
 
Your script would correctly set $name to use the right color when it found the correct name, BUT... it would then compare it against the next name, which it wouldn't match, so it changed back to white. Philipp wrote it so that it would only change the color if you didn't already find it. Another way to do it is to set it white first, then walk through the array:
 
 
@specialpeeps = ("O.A.P.", "Blakflagg", ...);
 
$name = "< font color = ' white' >$alias";
 
foreach $i (@specialpeeps) {
if ($alias eq "$i")
{
$name = "< font color = '#CCCC33' > $alias";
}
}
 
 
Not that Philipp's way is bad - in Perl, there are MANY different ways of accomplishing the same task. I just like this way better, because you end up do fewer assignments.

data/avatar/default/avatar15.webp

143 Posts
Location -
Joined 2000-04-18
OP
why'd it work ok at first though?
 
 
Also thanks a lot, it is workin great. I used Philipp's method and just tested it and it works so I'm happy

data/avatar/default/avatar19.webp

690 Posts
Location -
Joined 2000-05-21
Why not use the pretty formatting that this message board has to offer ?
 

Code:
@specialpeeps = ("O.A.P.", "Blakflagg", "O.T.A.", "Smokin_Gunz", "Godiwill", "Pittdog", "ReggieReg","Prophet", "Rapture", "Knight", "Antimatter", "shr1nk", "Ronin", "aeflux", "Apollo","Mindphlux", "Renderer", "Paradox", "StevenKao", "Meadeiac", "Net$ushi", "GodCani","The_Milkman", "RogueDawg", "Girl Injector", "nicad", "Oz|zY"); $found = "No"; foreach $i (@specialpeeps) { if ($found eq "No") { if ($alias eq "$i") { $name = "< font color = '#CCCC33' > $alias"; $found = "Yes"; }else { $name = "< font color = ' white' >$alias"; } } }

data/avatar/default/avatar15.webp

143 Posts
Location -
Joined 2000-04-18
OP
Cause it stretches the screen and I didn't know about it and there is no real need Although it's a very cool feature.