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.
Page 1 of 1
PERL Help
#2
Posted 13 June 2001 - 03:44 AM
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 = "< font color = '#CCCC33' > $alias";
$found = "Yes";
}else {
$name = "< font color = ' white' >$alias";
}
}
}
@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";
}
}
}
#3
Posted 13 June 2001 - 04:24 AM
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.
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.
#4
Posted 13 June 2001 - 06:48 AM
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
Also thanks a lot, it is workin great. I used Philipp's method and just tested it and it works so I'm happy
#5
Posted 13 June 2001 - 11:17 AM
Why not use the pretty formatting that this message board has to offer ?:D
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"; } } }
#6
Posted 13 June 2001 - 08:40 PM
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. :p
Share this topic:
Page 1 of 1

Help










