simme: perl script : html code modifizieren

hallo,

ich habe ein perl script für umfragen, in dem ich gerne den html-code modifizieren will.

das script in äktschn: http://www.mothertonguelives.de/tmp/basteln/relaunch/polltest.shtml

ich hätte gern, dass der text bei den resultaten nich direkt hinter den jeweiligen balken steht, sondern am rechten rand der box mit rechtsbündiger ausrichtung.

also müsste ich eine zweite tabellenzelle mit align=right einfügen richtig? die frage ist nur WO genau!?

der script-code:

surveysays(); exit;

sub surveysays {   initialize_data();

# Handle absence of HTTP_REFERER if possible   if (!$ENV{HTTP_REFERER} && $PANIC_URL) { $ENV{HTTP_REFERER} = $PANIC_URL }

# get form parameters   my $f = get_params();

# If person has already voted, return results   check_for_vote();

# Results only, if that's what was requested   return_results('only') if $ENV{QUERY_STRING} =~ /show_results/;

# Take Care of the Vote, if any   register_vote($f) if $ENV{QUERY_STRING} eq $POLL_CODE;

# If none of the above, return quiz   return_quiz();

}

sub initialize_data {     lock_data(LOCK_EX) or error("Couldn't lock file");     unless (-z $DATAFILE || !-e $DATAFILE) {         unlock_data();         return;     }     open(FILE,">$DATAFILE") or error('Error writing file');     print FILE 'CHOICES|||';     for (my $i = 1; $i <= scalar(@CHOICES); $i++) {         print FILE '0';         print FILE '|||' unless ($i == scalar(@CHOICES));     }     print FILE "\nIPS|||";     for (my $i = 1; $i <= $IPS_CACHED; $i++) {         print FILE '0.0.0.0';         print FILE '|||' unless ($i == $IPS_CACHED);     }     close(FILE);     unlock_data(); }

sub check_for_vote {

return_results() if $ARCHIVE;

lock_data(LOCK_SH) or error("Couldn't lock file");     open(FILE,"<$DATAFILE") or error('Error opening file');     chomp(my $totals = <FILE>);     chomp(my $ips = <FILE>);     close(FILE);     unlock_data();

my ($check1,@totals) = split(/|||/,$totals);     my ($check2,@ips) = split(/|||/,$ips);

# Error Checking     error('Data file corrupted')         unless ($check1 eq 'CHOICES' && $check2 eq 'IPS');

my $voted;

# ip check     if ($CHECK_BY =~ /(ip|all)/ && $IPS_CACHED > 0) {         for my $ip (@ips) {             $voted++ if $ip eq $ENV{REMOTE_ADDR};         }     }

# cookie check     if ($CHECK_BY =~ /(cookie|all)/) {         my $cgi = new CGI;         $voted++ if ($cgi->cookie($POLL_CODE) eq 'voted');     }

return_results() if $voted; }

sub register_vote {     my $f = shift;

# get the lock     lock_data(LOCK_EX) or error("Couldn't lock file");

# get the current data     open(FILE,"<$DATAFILE") or error('Error opening data file');     chomp(my $totals = <FILE>);     chomp(my $ips = <FILE>);     close(FILE);

my ($check,@totals) = split(/|||/,$totals);     my ($check2,@ips) = split(/|||/,$ips);     shift @ips while scalar(@ips) >= $IPS_CACHED;

# Error Checking     error('Data file corrupted') unless $check eq 'CHOICES';     error('Number of choices has changed')         unless scalar(@CHOICES) == scalar(@totals);

# Count the vote     $totals[$f->{quiz}-1]++ if defined($totals[$f->{quiz}-1]);

# write the new data file     my $write_file = ($TMP_DIR) ?  "$TMP_DIR/$$" . time . ".ss" : $DATAFILE;     open(FILE,">$write_file") or error('Error writing file');     print FILE 'CHOICES|||', join('|||',@totals), "\n";     print FILE 'IPS|||', join('|||',@ips), "|||$ENV{REMOTE_ADDR}";     close(FILE);

# Copy file if we used a temp one     if ($TMP_DIR) { rename($write_file,$DATAFILE)         or error('Error replacing data file') }

# unlock file     unlock_data();

# Cache Supression Code     my $add_on = ($SUPPRESS_CACHE) ? '?survey' . int(rand(99999)) : '';

# Return to page     print "Location: $ENV{HTTP_REFERER}$add_on\n";

# Try to set cookie if desired     if ($CHECK_BY =~ /^(cookie|all)$/) {         my $cgi = new CGI;         $COOKIE_DAYS = 60 if $COOKIE_DAYS =~ /\D/;         my $cookie = $cgi->cookie(-name    => $POLL_CODE,                                   -value   => 'voted',                                   -expires => "+${COOKIE_DAYS}d",                                   -path    => '/',                                   -domain  => $COOKIE_REALM);         print $cgi->header(-cookie=>$cookie);     }

print "\n";     exit; }

sub return_quiz {     lock_data(LOCK_SH) or error("Couldn't lock file");     open(FILE,"<$DATAFILE") or error('Error opening data file');     chomp(my $totals = <FILE>);     close(FILE);     unlock_data();

my ($check, @totals) = split (/|||/,$totals);

# Error Checking     error('Data file corrupted') unless $check eq 'CHOICES';     error('Number of choices has changed')         unless scalar(@CHOICES) == scalar(@totals);

# Return Table     print header, table_top(), <<END; <form action="$SCRIPT_URL?$POLL_CODE" method="POST" style="margin:0;"> END     for (my $i = 1; $i <= scalar(@CHOICES); $i++) {         print "<input type=radio name=quiz value="$i">$CHOICES[$i-1]<br>";     }     print <<END; <br><center><input type=submit value="Vote!"></center></form> END     if ($WITHOUT_VOTE) {         print <<END;

END     }     print table_bottom();     exit; }

sub return_results {     my $arg = shift;

lock_data(LOCK_SH) or error("Couldn't lock file");     open(FILE,"<$DATAFILE") or error('Error opening data file');     chomp(my $totals = <FILE>);     close(FILE);     unlock_data() or error('Error unlocking file');

my ($check, @totals) = split (/|||/,$totals);

# Error Checking     error('Data file corrupted') unless $check eq 'CHOICES';     error('Number of choices has changed')         unless scalar(@CHOICES) == scalar(@totals);

my ($mastertotal,@processed);     for (my $i = 0; $i < scalar(@CHOICES); $i++) {         $mastertotal += $totals[$i];         push(@processed,"$totals[$i]|||$CHOICES[$i]");     }     if ($SORT_RESULTS_BY eq 'low') {         @processed = sort {$a <=> $b} (@processed);     } elsif ($SORT_RESULTS_BY ne 'given') {         @processed = sort {$b <=> $a} (@processed);     }

print header, <<END; <table border=0 width=$TABLE_WIDTH cellspacing=0 cellpadding=2 style="margin-left:8px;"><tr> <td valign=center align=middle bgcolor="$TOP_COLOR" style="padding-bottom:10px;"> <b>$POLL_NAME</b></td></tr> <tr><td valign=top align=left bgcolor="$BOT_COLOR"> $QUESTION\n END     if ($mastertotal < $SHOW_VOTES_AFTER) {         print <<END; Please check back later for the results. END         print table_bottom();         exit;     }     for (my $i = 0; $i < scalar(@CHOICES); $i++) {         my ($num,$what) = split(/|||/,$processed[$i]);         my $percent = sprintf("%3.2f",($num/($mastertotal || 1))*100);         if ($GRAPHICAL) {              my $width = int($percent * $GR_SCALE);              print <<END; <img align=absmiddle src="$GR_FILE" height="$GR_HEIGHT" width="$width">&nbsp;&nbsp;

END         }         print "$what<br>\n";      }

if ($REPORT_TOTAL_VOTES) {         print "<br><div align=center>Total Votes: $mastertotal</div>\n";     }

if ($arg eq 'only') {     }

print table_bottom();     exit; }

sub table_top {     return <<END; <table border="0" width="$TABLE_WIDTH" cellspacing="0" cellpadding="2"> <tr><td valign="middle" align="center" bgcolor="$TOP_COLOR"> <b>$POLL_NAME</b> </td></tr> <tr><td valign="top" align=left bgcolor="$BOT_COLOR"> $QUESTION END }

sub table_bottom {     # The GPL says you can do what you want, so comment the credit out if you     # must.  It's not much of a "customization" though.     return <<END; </td></tr></table> END }

sub error {     print header, table_top(), "[Error: ", shift, "]<br>",           table_bottom();     exit; }

sub get_params {     my $f;     for my $key (param()) { $f->{$key} = join (' ',param($key)) }     return $f; }

{

local *SEM;

sub lock_data {         my $type = shift;         open(SEM,">$SEMAPHORE") or return undef;         flock(SEM,$type) or return undef;         return 1;     }

sub unlock_data {         close(SEM);     }

}

danke für eure hilfe, simme