Re: [ILUG] Re: unison

From: Fergal Daly (fergal at domain esatclear.ie)
Date: Sat 12 Feb 2000 - 01:28:31 GMT


Here's the perl equivalent, it takes a few more characters to open the
socket but apart from that they're pretty much the same. They are both way
too lean for my liking, no error checking going on anywhere in either of them.

use IO::Socket;

$socket = IO::Socket::INET->new(
        PeerAddr => "ntp.maths.tcd.ie",
        PeerPort => 13,
);

exec "/usr/bin/date -s ".<$socket>;

if you're really hell bent on leanness you could go all out with

use IO::Socket;

exec "/usr/bin/date -s ".IO::Socket::INET->new(qw(PeerAddr ntp.maths.tcd.ie
PeerPort 13))->getline;

but that's just silly,

Fergal

At 00:44 12/02/00 +0000, John McCormac wrote:
>Perl is a good language for many things like a Swiss Army Knife of
>programming, but tcl is a fairly nifty language for messing about with
>webpages (ie reusing other people's web data) and implementing something
>that approaches ASP (both ASP and the persistant connections ideas were
>bought by Microsoft rather than developed by them.) What surprised me
>about it was the ease with which something could be accomplished. Some
>of the boxes here suffer from clock drift so I have a tcl script on a
>cron job synching a box with net time. I was using the Perl script from
>Linux journal (which works well) but a few seconds with tcl produced a
>script that did the same thing:
>
>#!/usr/bin/tclsh
>set sockid [socket ntp.maths.tcd.ie 13]
>gets $sockid newdate
>puts $newdate
>set e [exec date -s $newdate]
>
>The tcl code appears leaner, (I was worried that it was too lean), than
>the Perl equivalent. What would really be interesting would be if
>someone could achieve something approaching AOLserver's pooling with
>Apache and mod-tcl.



This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:05:24 GMT