Forum Moderators: coopster & phranque

Message Too Old, No Replies

Im haveing problems with my send data code

send game data to email or data base email

         

GameDeveloper

2:23 pm on Jun 30, 2003 (gmt 0)

10+ Year Member



I have this code to send email to my account the stats of the people in my game so i can put them on a highscores list but i get alot of erros about his ill post them:
(the variables $heroname $defense $speed and $strength are defined in my game code)

Errors:

Global symbol "$length" requires explicit package name at comple
5.
Global symbol "$packFormat" requires explicit package name at co
e 206.
Global symbol "$packFormat" requires explicit package name at co
e 210.
Missing right curly or square bracket at complexgame.pl line 265

syntax error at complexgame.pl line 265, at EOF
Execution of complexgame.pl aborted due to compilation errors.

HERES THE CODE:
<!----Code Begins here----!>
print "In the below box post your character name and send it to me for a place on the list!\n";
use Socket;
use strict;

my($mailTo) = 'name@site.net';

my($mailServer) = 'mail.site.net';

my($mailFrom) = '<stdin>';
my($realName) = "<stdin>";
my($subject) = '<stdin>';
my($body) = "${heroname} ${strength} ${defense} ${speed} (do not edit this line)\nWrite message here(this line).\n";

$main::SIG{'INT'} = 'closeSocket';

my($proto) = getprotobyname("tcp") ¦¦ 6;
my($port) = getservbyname("SMTP", "tcp") ¦¦ 25;
my($serverAddr) = (gethostbyname($mailServer))[4];

if (! defined($length)) {

die('gethostbyname failed.');
}

socket(SMTP, AF_INET(), SOCK_STREAM(), $proto)
or die("socket: $!");

$packFormat = 'S n a4 x8'; # Windows 95, SunOs 4.1+
#$packFormat = 'S n c4 x8'; # SunOs 5.4+ (Solaris 2)

connect(SMTP, pack($packFormat, AF_INET(), $port, $serverAddr))
or die("connect: $!");

select(SMTP); $¦ = 1; select(STDOUT); # use unbuffemiles i/o.

{
my($inpBuf) = '';

recv(SMTP, $inpBuf, 200, 0);
recv(SMTP, $inpBuf, 200, 0);
}

sendSMTP(1, "HELO\n");
sendSMTP(1, "MAIL From: <$mailFrom>\n");
sendSMTP(1, "RCPT To: <$mailTo>\n");
sendSMTP(1, "DATA\n");

send(SMTP, "From: $realName\n", 0);
send(SMTP, "Subject: $subject\n", 0);
send(SMTP, $body, 0);

sendSMTP(1, "\r\n.\r\n");
sendSMTP(1, "QUIT\n");

close(SMTP);

sub closeSocket { # close smtp socket on error
close(SMTP);
die("SMTP socket closed due to SIGINT\n");
}

sub sendSMTP {
my($debug) = shift;
my($buffer) = @_;

print STDERR ("> $buffer") if $debug;
send(SMTP, $buffer, 0);

recv(SMTP, $buffer, 200, 0);
print STDERR ("< $buffer") if $debug;

return( (split(/ /, $buffer))[0] );
}
<!----Code ends here----!>

lol if anyone wants to help me with mre code stuff (C++ and XML timing for moving vehicels in anoter game)

[edited by: jatar_k at 4:26 pm (utc) on June 30, 2003]
[edit reason] generalized email addresses [/edit]

andreasfriedrich

10:19 pm on Jul 1, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you use [perldoc.com] the strict [perldoc.com] pragma you will need to declare variables using either our [perldoc.com], my [perldoc.com], use [perldoc.com] vars [perldoc.com] (obsolete) or use fully qualified variable names $PACKAGE::variable.

Look for a missing bracket somewhere in your code to fix the second error.

Andreas