Apolyton Archive  |  Preserved copy of the Apolyton Civilization Site forums as they ran on Ultimate Bulletin Board, 1998–2001. Read-only; nothing here can be posted to or replied to.  |  Forum index |  About this archive |  The 2005 site & forums

Thread Closed  Thread Closed
  Apolyton Civilization Site Forums
  Freeciv
  any perl wizards in here?

Post New Topic  

profile | register | preferences | faq | search

next newest topic | next oldest topic bottom of page
Author
Topic:   any perl wizards in here? Format for Better Printing
MarkG
Apolyton CS Co-Administrator
Greece
b.02-15-99
posted June 16, 2000 12:50   Click Here to See the Profile for MarkGClick Here to Email MarkG  send a private message to MarkGSend a Message to UIN: 2865183 Visit MarkG's Homepage!
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
I need some help...
Thue
Freeciv Developer

b.02-15-99
posted June 16, 2000 13:03   Click Here to See the Profile for ThueClick Here to Email Thue  send a private message to ThueSend a Message to UIN: 18058911
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
I am by no means a perl wizard, but if you would describe the problem I can see if I can help!
paulz
Freeciv Host/Webmaster
San Diego, CA, USA
May 2000
posted June 16, 2000 14:08   Click Here to See the Profile for paulzClick Here to Email paulz  send a private message to paulz Visit paulz's Homepage!
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
I have been known to write a perl line or too as well...

Kumiorava
Prince
of the Elastic Mammals, retired
b.02-15-99
posted June 16, 2000 18:05   Click Here to See the Profile for KumioravaClick Here to Email Kumiorava  send a private message to KumioravaSend a Message to UIN: 14265035
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
quote:

Originally posted by MarkG on 06-16-2000 12:50 PM
I need some help...

And he looks for a place to find a perl wiz, and comes to the logical conclusion - the best must reside among the Linux peeps. Quite true.

deepone
Freeciv Developer

May 2000
posted June 16, 2000 19:05   Click Here to See the Profile for deepone   send a private message to deepone Visit deepone's Homepage!
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
Indeed...
MarkG
Apolyton CS Co-Administrator
Greece
b.02-15-99
posted June 16, 2000 19:36   Click Here to See the Profile for MarkGClick Here to Email MarkG  send a private message to MarkGSend a Message to UIN: 2865183 Visit MarkG's Homepage!
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
of course, what do stupid windows people know about perl?

ok, I've added this code on one of the forums scripts which limits the numbers of threads one can make per X days to 1(this is enabled only for the off-topic forum)

code:
# Multiple post per day check
if (($Status ne "Administrator") && ($Status ne "Moderator")) {
if ($number == 23) {
$numDaysToWait = 1;
@finalPList = ();
$nowListTime = time;
if (-e "$MembersPath/postedlist.cgi") {
open (POSTED, "$MembersPath/postedlist.cgi");
@postedList = ;
close (POSTED);
foreach $hasPosted (@postedList) {
($UserHP, $DateHP, $ForumNumHP) = split(/\|\!\|/, $hasPosted);
chomp($ForumNumHP);
if (($nowListTime - $DateHP) < ($numDaysToWait * 86400)) {
push @finalPList, $hasPosted;
if (($UserHP eq $UserName) && ($ForumNumHP == $number)) {
&StandardHTML("Sorry, but you may only post one new
topic in this forum once every $numDaysToWait day.");
exit;
}
}
}
}
open (POSTED, ">$MembersPath/postedlist.cgi");
print POSTED @finalPList;
print POSTED "$UserName|!|$nowListTime|!|$number\n";
close (POSTED);
chmod (0666, "$MembersPath/postedlist.cgi");
}
}

I want to limit a poster to X number of threads for X days(instead of 1 thread for X days)

I'm sure it's something easy, but above my level of perl knowledge

Mark von Wagner
Prince
of Peace
May 99
posted June 17, 2000 02:44   Click Here to See the Profile for Mark von WagnerClick Here to Email Mark von Wagner  send a private message to Mark von WagnerSend a Message to UIN: 38935358 Visit Mark von Wagner's Homepage!
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
I've never written a PERL program before, so I don't know how good or bad my style is, but this should do the job (give or take a few syntax errors).



if ((($Status ne "Administrator") && ($Status ne "Moderator")) | | ($UserName ne "Mark von Wagner")) {
if ($number == 23) {
$numDaysToWait = 1;
$numberOfThreads = 3;
@finalPList = ();
$nowListTime = time;
if (-e "$MembersPath/postedlist.cgi") {
open (POSTED, "$MembersPath/postedlist.cgi");
@postedList = ;
close (POSTED);
$userFound = 0;

foreach $hasPosted (@postedList) {
@DateHPs = ();
$slotsFound = 0;
($UserHP,$ForumNumHP,$DateHP) = split(/\|\!\|/, $hasPosted, 3);
chomp($DateHP);
for($counter1 = 0; $counter1 < $numberOfThreads; $counter1++) {
($dateTemp, $DateHP) = split(/\|\!\|/, $hasPosted, 2);
push @DateHPs, $dateTemp;
if(($nowListTime - $dateTemp) > ($numDaysToWait * 86400)) {
$slotsFound++;
}
}
if (($UserHP eq $UserName) && ($ForumNumHP == $number)) {
$userFound = 1;

if($slotsFound == 0) {
&StandardHTML("Sorry, but you may only post $numberOfThreads new topics in this forum every 24 hours.");
exit;
}
else {
$flag1 = 0;
$slotsFound = $slotsFound - 1;
$hasPosted = sprintf("%s|!|%s", $UserHP,$ForumNumHP);
foreach $dateTemp(@DateHPs) {
if ((($nowListTime - $dateTemp) > ($numDaysToWait * 86400)) && ($flag1 == 0)) {
$flag1 = 1;
$dateTemp = $nowListTime;
}
$hasPosted = sprintf("%s|!|%d",$hasPosted,$dateTemp);
}
}
push @finalPList, $hasPosted;
}
else if (($slotsFound < $numberOfThreads)) {
$hasPosted = sprintf("%s|!|%s", $UserHP,$ForumNumHP);
foreach $dateTemp(@DateHPs) {
$hasPosted = sprintf("%s|!|%d",$hasPosted,$dateTemp);
}
push @finalPList, $hasPosted;
}
}
if($userFound == 0){
$oldListTime = $nowListTime - 86400 * numDaysToWait;
$hasPosted = sprintf("%s|!|%s|!|%d", $UserHP,$ForumNumHP, $nowListTime);
for($counter1 = 0; $counter1 < $numberOfThreads; $counter1++) {
$hasPosted = sprintf("%s|!|%d",$hasPosted,$oldListTime);
}
push @finalPList, $hasPosted;
}
}
open (POSTED, ">$MembersPath/postedlist.cgi");
print POSTED @finalPList;
close (POSTED);
chmod (0666, "$MembersPath/postedlist.cgi");
}
}

Edit: Corrected indenting
[This message has been edited by Mark von Wagner (edited June 17, 2000).]
Thue
Freeciv Developer

b.02-15-99
posted June 17, 2000 05:06   Click Here to See the Profile for ThueClick Here to Email Thue  send a private message to ThueSend a Message to UIN: 18058911
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
Now, I don't have time for a real review right now, but reading the first line

if ((($Status ne "Administrator") && ($Status ne "Moderator")) | | ($UserName ne "Mark von Wagner")) {

The last | | should be an &&

MarkG
Apolyton CS Co-Administrator
Greece
b.02-15-99
posted June 17, 2000 05:17   Click Here to See the Profile for MarkGClick Here to Email MarkG  send a private message to MarkGSend a Message to UIN: 2865183 Visit MarkG's Homepage!
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
actually, the | | ($UserName ne "Mark von Wagner") part shouldnt exist

thanks Mark I'll give it a try

MarkG
Apolyton CS Co-Administrator
Greece
b.02-15-99
posted June 17, 2000 08:20   Click Here to See the Profile for MarkGClick Here to Email MarkG  send a private message to MarkGSend a Message to UIN: 2865183 Visit MarkG's Homepage!
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
minor problem 1
this code
code:
				else if (($slotsFound < $numberOfThreads)) {


should be
code:
				else { 
if (($slotsFound < $numberOfThreads)) {

with a } at the end of the if...

else if does not work on perl

[This message has been edited by MarkG (edited June 17, 2000).]

MarkG
Apolyton CS Co-Administrator
Greece
b.02-15-99
posted June 17, 2000 08:25   Click Here to See the Profile for MarkGClick Here to Email MarkG  send a private message to MarkGSend a Message to UIN: 2865183 Visit MarkG's Homepage!
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
bgier problem: something is wrong and the scripts write wrong things on the file...
Mark von Wagner
Prince
of Peace
May 99
posted June 17, 2000 23:16   Click Here to See the Profile for Mark von WagnerClick Here to Email Mark von Wagner  send a private message to Mark von WagnerSend a Message to UIN: 38935358 Visit Mark von Wagner's Homepage!
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
Sorry about the problems in my first version. As you can probably tell, I do most of my programming in C++, where things like "else if" are valid. Here is a corrected version that, at least in my tests, works correctly.



if (($Status ne "Administrator") && ($Status ne "Moderator")) {
if ($number == 23) {
$numDaysToWait = 1;
$numberOfThreads = 3;
$userFound = 0;
@finalPList = ();
$nowListTime = time;
if (-e "$MembersPath/postedlist.cgi") {
open (POSTED, "$MembersPath/postedlist.cgi");
@postedList = ;
close (POSTED);
foreach $hasPosted (@postedList) {
@DateHPs = ();
$slotsFound = 0;
($UserHP,$ForumNumHP,$DateHP) = split(/\|\!\|/, $hasPosted, 3);
chomp($DateHP);
for($counter1 = 0; $counter1 < $numberOfThreads; $counter1++) {
($dateTemp, $DateHP) = split(/\|\!\|/, $DateHP, 2);
push @DateHPs, $dateTemp;
if(($nowListTime - $dateTemp) > ($numDaysToWait * 86400)) {
$slotsFound++;
}
}
if (($UserHP eq $UserName) && ($ForumNumHP == $number)) {
$userFound = 1;

if($slotsFound == 0) {
&StandardHTML("Sorry, but you may only post $numberOfThreads new topics in this forum every 24 hours.");
exit;
}
else {
$flag1 = 0;
$slotsFound = $slotsFound - 1;
$hasPosted = sprintf("%s|!|%s", $UserHP,$ForumNumHP);
foreach $dateTemp(@DateHPs) {
if ((($nowListTime - $dateTemp) > ($numDaysToWait * 86400)) && ($flag1 == 0)) {
$flag1 = 1;
$dateTemp = $nowListTime;
}
$hasPosted = sprintf("%s|!|%d",$hasPosted,$dateTemp);
}
}
$hasPosted = sprintf("%s\n",$hasPosted);
push @finalPList, $hasPosted;
}
else {
if (($slotsFound < $numberOfThreads)) {
$hasPosted = sprintf("%s|!|%s", $UserHP,$ForumNumHP);
foreach $dateTemp(@DateHPs) {
$hasPosted = sprintf("%s|!|%d",$hasPosted,$dateTemp);
}
$hasPosted = sprintf("%s\n",$hasPosted);
push @finalPList, $hasPosted;
}
}
}
}
if($userFound == 0){
$oldListTime = $nowListTime - (86400 * $numDaysToWait);
$hasPosted = sprintf("%s|!|%s|!|%d", $UserName,$number, $nowListTime);
for($counter1 = 1; $counter1 < $numberOfThreads; $counter1++) {
$hasPosted = sprintf("%s|!|%d",$hasPosted,$oldListTime);
}
$hasPosted = sprintf("%s\n",$hasPosted);
push @finalPList, $hasPosted;
}
open (POSTED, ">$MembersPath/postedlist.cgi");
print POSTED @finalPList;
close (POSTED);
chmod (0666, "$MembersPath/postedlist.cgi");
}
}


[This message has been edited by Mark von Wagner (edited June 17, 2000).]
MacHatter
Settler

Jun 2000
posted June 17, 2000 23:33   Click Here to See the Profile for MacHatter   send a private message to MacHatter
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
quote:

Originally posted by MarkG on 06-17-2000 08:20 AM

else if does not work on perl

[This message has been edited by MarkG (edited June 17, 2000).]

I belive that the perl version of else if is elsif. It's been about a month since I was working with perl, so I may be wrong, but I don't think so Yep, I was right.

PS. Could I get the title freeciv porter?

------------------
Andy Black
----------
Mac Port manager for Freeciv

Mark von Wagner
Prince
of Peace
May 99
posted June 28, 2000 00:54   Click Here to See the Profile for Mark von WagnerClick Here to Email Mark von Wagner  send a private message to Mark von WagnerSend a Message to UIN: 38935358 Visit Mark von Wagner's Homepage!
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
MarkG, have you gotten around to testing my modifications yet?
MarkG
Apolyton CS Co-Administrator
Greece
b.02-15-99
posted June 29, 2000 14:01   Click Here to See the Profile for MarkGClick Here to Email MarkG  send a private message to MarkGSend a Message to UIN: 2865183 Visit MarkG's Homepage!
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
not yet
Richard Cranium
Chieftain

Jun 2000
posted July 11, 2000 00:55   Click Here to See the Profile for Richard Cranium   send a private message to Richard Cranium
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
In regards to a post in the Apolyton forum:
BUMP

*sounds of 6367 feet tapping*

Edit: just testing a hypothesis...
[This message has been edited by Richard Cranium (edited July 21, 2000).]

Murgatroyd
Warlord
95 South, 113 West
Feb 2000
posted September 02, 2000 16:39   Click Here to See the Profile for Murgatroyd   send a private message to MurgatroydSend a Message to UIN: 31415926535
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
In regards to a post in the Off-Topic forum:
BUMP

*sounds of 6717 feet tapping*

Murgatroyd
Warlord
95 South, 113 West
Feb 2000
posted September 13, 2000 01:02   Click Here to See the Profile for Murgatroyd   send a private message to MurgatroydSend a Message to UIN: 31415926535
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
An additional BUMP. This thread will not be forgotten!
ProvostQ
Settler
Hollywood, California, USA
Sep 2000
posted September 13, 2000 17:57   Click Here to See the Profile for ProvostQ   send a private message to ProvostQSend a Message to UIN: 12062352303 Visit ProvostQ's Homepage!
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
I don't consider myself a perl wizard. A perl sourcerer, maybe.
MarkG
Apolyton CS Co-Administrator
Greece
b.02-15-99
posted September 13, 2000 19:02   Click Here to See the Profile for MarkGClick Here to Email MarkG  send a private message to MarkGSend a Message to UIN: 2865183 Visit MarkG's Homepage!
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
this thread has served it's purpose
lets leave the forum for it's real use...
Apolyton Civilization Site Forums
> > > Freeciv Forum

next newest topic | next oldest topictop of page

All times are EDT

Administrative Options: Open Topic | Archive/Move | Delete Topic | Top
Post New Topic  
Hop to:

Contact Us
Apolyton Civilization Site

Powered by: Ultimate Bulletin Board, Version 5.44a
© Infopop Corporation (formerly Madrona Park, Inc.), 1998 - 2000.

Front Page | Civilization III | Dinosaurs | Civilization II | Call to Power | Call to Power II | Alpha Centauri | Alternative Civs | Misc | Links | About ACS | GameStats
GameLeague | Scenario League | Hodadian Award Central | Civilization Scenario Collection | Spanish CivII Site | Clash of Civs | CtP Maps