CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
How to generate UUID for DocumentID and InstanceID

 



srikrishnan
Novice

Dec 3, 2008, 10:12 PM

Post #1 of 2 (1226 views)
How to generate UUID for DocumentID and InstanceID Can't Post

Hi All,

I am trying to add XMP metadata in our pdf files. For this I need to generate UUID for the following XMP fields

<xmpMM:DocumentID>uuid:27bf4dc2-daa2-46a0-9944-4aeea86cb8d0</xmpMM:DocumentID>
<xmpMM:InstanceID>uuid:27f7c7ea-bde3-49fd-b76b-0975741cc5d9</xmpMM:InstanceID>

I am trying perl module "DATA::UUID" for the above requirement. But I dont know how to generate the above two UUIDS for our each pdf.
Please anybody can help me

Regards,
Srikrishnan


TomS_
New User

Dec 30, 2008, 3:01 AM

Post #2 of 2 (1018 views)
Re: [srikrishnan] How to generate UUID for DocumentID and InstanceID [In reply to] Can't Post

Well, technically speaking, you should never be able to generate the same UUID or GUID twice. They are meant to be different such that they can be relied upon to be (reasonably) unique (what ever the probability is of generating the same sequence of 128 bits is).

But IIRC UUIDs arent entirely random, they are based on time, aswell as some randomness. This means that you should never see the same UUID twice, because time is always increasing and seconds of time rarely repeat.

Unless I dont understand your question correctly, I dont see what is so difficult? I whipped this script up in about two minutes (including the time taken to install Data::UUID from CPAN):


Code
#!/usr/local/bin/perl 

use strict;

use Data::UUID;

my $ug = new Data::UUID;
my $uuid = $ug->create();

print "\n" . $ug->to_string($uuid) . "\n\n";

1;


Running the script gives me:


Code
[building 21:28]/home/tom/perl>	./uuid 

D70CE142-D660-11DD-B94C-C6F8E2A78DDD

[building 21:28]/home/tom/perl> ./uuid

D906E52E-D660-11DD-9926-C7F8E2A78DDD

[building 21:28]/home/tom/perl> ./uuid

DAB20908-D660-11DD-8333-C8F8E2A78DDD

[building 21:28]/home/tom/perl> ./uuid

DB7E2ABA-D660-11DD-8B6B-C9F8E2A78DDD

[building 21:28]/home/tom/perl> ./uuid

DC1BBBF4-D660-11DD-8388-CAF8E2A78DDD


Pretty simple it seems?

Hope that helps you. :-)

Tom


(This post was edited by TomS_ on Dec 30, 2008, 3:08 AM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives