pack.txt
use Socket;
use strict;
use warnings;
my @input = (
inet_aton('127.0.0.1'),
2**16-1,
time,
'hello world',
);
my $packed = pack 'A4 S I A*', @input;
my @output = unpack 'N S I A*', $packed;
#my $sth = $dbh->prepare(q[
# INSERT INTO table
# (address, port, time, message)
# VALUES(INET_NTOA(?), ?, FROM_UNIXTIME(?), ?)
# ]);
#
#$sth->execute(@output);
while(@input) {
my $input = shift @input;
my $output = shift @output;
if($input eq $output) {
print "packed output ok\n";
}
else {
printf "packed output not ok %s != %s\n", $input, $output;
}
}