Home > Archive > PERL Programming > August 2007 > Create Unique Message-ID
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Create Unique Message-ID
|
|
|
| Hi,
I've scoured google for this, and have found lots of possible solutions,
but none seems to work.
I'm trying to create a unique Message-ID that will go in the top of a
Usenet post. So obviously, each ID has to be unique, and I did this once
before, but can't remember how. I think I did my $id = `date`; or
something and then when it came to creating the header, it was
$message_id=$id, "@yahoo.fr" or something.
The problem is that `date`generates the date in .. well, in the wrong
format. I need it in like say just seconds. So I can have unique IDs like
"9283736663616@yahoo.fr" or something.
Help!
| |
| Mumia W. 2007-06-23, 3:59 am |
| On 06/22/2007 05:45 AM, yig wrote:
> Hi,
> I've scoured google for this, and have found lots of possible solutions,
> but none seems to work.
>
> I'm trying to create a unique Message-ID that will go in the top of a
> Usenet post. So obviously, each ID has to be unique, and I did this once
> before, but can't remember how. I think I did my $id = `date`; or
> something and then when it came to creating the header, it was
> $message_id=$id, "@yahoo.fr" or something.
>
> The problem is that `date`generates the date in .. well, in the wrong
> format. I need it in like say just seconds. So I can have unique IDs like
> "9283736663616@yahoo.fr" or something.
>
> Help!
>
>
I don't think you should use @yahoo.fr unless you're the company Yahoo
in France.
Anyway, Perl's time() function returns the time in seconds since an epoch.
#!/usr/bin/perl
print time() . '@mydomian.example.com';
__HTH__
| |
|
| Mumia W. <paduille.4061.mumia.w+nospam@earthlink.net> wrote:
> On 06/22/2007 05:45 AM, yig wrote:
[color=darkred]
> I don't think you should use @yahoo.fr unless you're the company Yahoo
> in France.
You're quite right, of course. My bad.
[color=darkred]
> Anyway, Perl's time() function returns the time in seconds since an epoch.
>
> #!/usr/bin/perl
> print time() . '@mydomian.example.com';
It does: many thanks.
| |
| Joe Smith 2007-06-23, 3:59 am |
| yig wrote:
> I'm trying to create a unique Message-ID that will go in the top of a
> Usenet post. So obviously, each ID has to be unique,
I would use an ID that includes the time, includes a counter (in case more
than one message per second), includes the process-ID (in case multiple
instances running at the same time), and includes the host name (required).
my $hostname = 'yahoo-fr.example.com';
for (my $count = 0;; ++$count) {
my $message_id = time() . ".$count.$$.$domain";
send_message($message_id);
}
-Joe
| |
| Dr.Ruud 2007-06-23, 10:02 pm |
| Joe Smith schreef:
> yig:
>
> I would use an ID that includes the time, includes a counter (in case
> more than one message per second), includes the process-ID (in case
> multiple instances running at the same time), and includes the host
> name (required).
>
> my $hostname = 'yahoo-fr.example.com';
> for (my $count = 0;; ++$count) {
> my $message_id = time() . ".$count.$$.$domain";
> send_message($message_id);
> }
ITYM: my $message_id = time() . ".$count.$$\@$hostname";
You could reset $count when time() has changed.
my $hostname = 'yahoo-fr.example.com';
my $time = time;
my $count = 0;
for my $msg (@messages) {
++$count;
$msg->message_id( qq{$time.$count.$$\@$hostname} );
if ( (my $t = time) != $time ) {
$time = $t;
$count = 0;
}
}
--
Affijn, Ruud
"Gewoon is een tijger."
| |
|
|
|
|
|
|
|
|
|