Busby 0 Posted June 13, 2001 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. Share this post Link to post
Philipp 6 Posted June 13, 2001 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"; } } } Share this post Link to post
CUViper 0 Posted June 13, 2001 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. Share this post Link to post
Busby 0 Posted June 13, 2001 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 Share this post Link to post
Xiven 0 Posted June 13, 2001 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"; } } } Share this post Link to post
Busby 0 Posted June 13, 2001 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. Share this post Link to post