Finally a better script!



You understand very quickly what i wanted to do and you helped me write the correct way.
After all of the guys suggestions here is how the script transformed:



========================================================= my $script = param('select') || "Welcome Page!"; my ($data, @data);


if (param('select') and param('select') ne '..') { open(FILE, "<../data/text/$script.txt") or die $!; @data = <FILE>; close(FILE);

    $data = join('', @data);

$dbh->do( "UPDATE guestlog SET script='$script' WHERE host='$host'" ) or die $dbh->errstr;
}
else
{
$sth = $dbh->prepare( "SELECT host FROM guestlog WHERE host=?" );
$sth->execute($host);


if ($sth->rows)
{
$sth = $dbh->prepare( "UPDATE guestlog SET hostcount=hostcount+1 WHERE host=?" );
$sth->execute($host);


        $sth = $dbh->prepare( "SELECT * FROM guestlog WHERE host=?" );
        $sth->execute($host);
        $row = $sth->fetchrow_hashref;

$data = "Êáëþò Þëèåò " .$host. "! ×áßñïìáé ðïõ âñßóêåò ôçí óåëßäá åíäéáöÝñïõóá!\n" .
"Ôåëåõôáßá öïñÜ Þñèåò åäþ ùò " .$row->{host}. " óôéò " ..$row->{date}. " !!\n" .
"ÓýíïëéêÝò Þñèåò åäþ " .$row->{hostcount}. " öïñÝò!!!\n" .
"Ôåëåõôáßá åßäåò ôï êåßìåíï { " .$row->{script}. " }\n" .
"Ðïéü êåßìåíï èá ìåëåôÞóåòé áõôÞí ôçí öïñÜ !?";
}
else
{
if ($host ne "Íßêïò")
{
$data = "ÃåéÜ óïõ " .$host. "!\n" .
"¸ñ÷åóáé ãéá 1ç öïñÜ åäþ !!\n" .
"Åëðßæù íá âñåßò ôá êåßìåíá åíäéáöÝñïíôá :-)";


            $sth = $dbh->prepare("SELECT * FROM guestlog WHERE host=?");
            $sth->execute($host);

$sth = $dbh->prepare( "INSERT INTO guestlog (host, date, script, hostcount, pagecount) VALUES (?, ?, ?, ?, ?)" );
$sth->execute($host, $date, $script, $hostcount, $pagecount);
}
else
{
$data = "ÃåéÜ óïõ Íéêüëá, ôé ÷áìðÜñéá?! ¼ëá äåîéÜ íá óïõ ðÜíå ðÜíôá! ;-)";
}
}
}
=========================================================



I wish i can test ti but iam currently having a mysql problem but thing it will work :-)
If we still can make it shorter please let me know!
.




Relevant Pages

  • Re: Ahem.
    ... A shag would be shorter. ... Speak for yourself. ... "live fast, die only if strictly necessary" ...
    (uk.misc)
  • Re: get string within ""
    ... this client. ... This is one of the cases where the equivalent sed command is both ... shorter and IMHO more intuitive. ... Brüder, in die Tonne die Freiheit, ...
    (comp.unix.shell)
  • Re: While Harry is Alive....:
    ... yes yes, Harry must die. ... How else can she possibly tie up all of the ... lose ends otherwise in one book that's suppose to be shorter than OoTP? ...
    (alt.fan.harry-potter)