CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Some Probelm

 



wickedxter
User

Jun 3, 2001, 9:35 PM

Post #1 of 6 (1521 views)
Some Probelm Can't Post

i've attacked the script..

probelm: to hard to explain. Try out the script and then tell me whats wrong and why it's doing that.



randor
User

Jun 4, 2001, 3:46 AM

Post #2 of 6 (1510 views)
Re: Some Probelm [In reply to] Can't Post

your attachment is not showing up...

I Hope this helps...

perl programmers don't die.. they just start writing a new script.


Jasmine
Administrator / Moderator

Jun 4, 2001, 6:58 AM

Post #3 of 6 (1506 views)
Re: Some Probelm [In reply to] Can't Post

Hard to figure out what's wrong with it without the data file that's being used to display the results ...

Care to upload it?



wickedxter
User

Jun 4, 2001, 9:52 PM

Post #4 of 6 (1497 views)
Re: Some Probelm [In reply to] Can't Post

ok here ill just post it....

#!Perl

#use strict;
#!perl

# This displayes current ladder and players(ranks them).
# v1.0

# copyright wickedxter 2001-2002 All Rights Resurved.
#----------------------------------------------------------

use CGI;
use CGI::Carp qw(fatalsToBrowser);
my $q = new CGI;
print $q->header;

my $prog_url = "/cgi-bin/ladder/ladder.cgi";
my $data_file = "/perl2/cgi-bin/ladder/data";
my $num_lines = 10;

my(@lines);
my($start,$finish) = (0,$num_lines);

if( $q->param('start') ne '' && $q->param('end') ne '' && $q->param('ladder') ne ''){
($start,$num_sta) = split( '/=/' , $q->param('page') );
($finish,$num_fin) = split( '/=/' , $q->param('end') );
($crap,$id) = split('/=/' , $q->param('ladder') );
open(DATAF,"<$data_file/$crap/ladder/ladder.txt") or die("Cannot open $data_file/$id/ladder/ladder.txt: $!");
while(<DATAF>){
if($. > $start && $. <= $finish){
push(@lines,$_);
}
}
$start = $finish;
$finish = $finish + $num_lines;
close(DATAF);
}

print <<EndHtml;
<body bgcolor="#000000" text="#FFFFFF" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF">

<div align="center">
<center>
<table border="1" width="69%" cellspacing="0" cellpadding="0" bordercolor="#000000">
<tr>
<td width="8%" bgcolor="#6F2424" align="center"><font face="Verdana" size="2"><b>Rank</b></font></td>
<td width="23%" bgcolor="#6F2424" align="center"><font face="Verdana" size="2"><b>Player/Clan</b></font></td>
<td width="21%" bgcolor="#6F2424" align="center"><font face="Verdana" size="2"><b>Wins/Loses</b></font></td>
<td width="32%" bgcolor="#6F2424" align="center"><font face="Verdana" size="2"><b>Challenge</b></font></td>
<td width="16%" bgcolor="#6F2424" align="center"><font face="Verdana" size="2"><b>Match</b></font></td>
</tr>
EndHtml
;
$number = $start - $num_lines;
@lines = sort{$b <=> $a} @lines;
foreach $line (@lines){
($rank_score,$wins,$loses,$player,$challenge,$m_code) = split(/\|/,$line);
$number++;
if($challenge eq "Free"){ $challenge = "Free"; }
if($m_code eq ""){ $m_info = ""; }
elsif($m_code ne ""){ $m_info = "<a href=\"view_match.cgi?match_id=$m_code\">Match Info</a>"; }
print <<EndHtml;
<tr>
<td width="8%" bgcolor="#431616" align="center"><font face="Verdana" size="2">$number</font></td>
<td width="23%" bgcolor="#431616" align="center"><font face="Verdana" size="2">$player</font></td>
<td width="21%" bgcolor="#431616" align="center"><font face="Verdana" size="2">$wins/$loses</font></td>
<td width="32%" bgcolor="#431616" align="center"><font face="Verdana" size="2">$challenge</font></td>
<td width="16%" bgcolor="#431616" align="center"><font face="Verdana" size="2">$m_info</font></td>
</tr>
EndHtml
;
}
print <<EndHtml;
</table>
</center>
</div>
EndHtml
;
$start2 = $start - (2 * ($num_lines));
$finish2 = $finish - (2 * ($num_lines));
if($finish2 eq 0){
$back_link = "";
}
if($start2 eq -20){
$back_link = "";
}
else {
$back_link = "[<a href=$prog_url?start=$start2&end=$finish2&ladder=$crap>Back</a>]";
}
if($start eq "" || $finish eq ""){
$next_link = ""
}
else {
$next_link = "[<a href=$prog_url?start=$start&end=$finish&ladder=$crap>Next</a>]";
}
print "<table border=\"1\" width=\"85%\" cellspacing=\"0\" cellpadding=\"0\" bordercolor=\"#000000\">";
print "<tr>";
print "<td>";
print "<p align=right><font face=verdana size=2>$back_link$next_link</font></p>";
print "</td></tr></table>";
print "$start|$finish";




wickedxter
User

Jun 4, 2001, 9:53 PM

Post #5 of 6 (1497 views)
Re: Some Probelm [In reply to] Can't Post

the data file contains:

stuff like this(just test info):

3|7|4|DumbAss|Challenged|1|
5|5|0|Wicked|Challenged|1|
8|10|3|person|Free||
15|18|3|you|Free||
23|24|1|Fucker|Free||
7|7|0|BestMFER|Free||
0|0|0|1|New||
0|0|0|2|New||



wickedxter
User

Jun 5, 2001, 2:55 PM

Post #6 of 6 (1488 views)
Re: Some Probelm [In reply to] Can't Post

ok NM this topic i've fixed the probelm


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives