Hi,
I am not sure that you got the mail after this where I made the feed back from David Golden.

The solution was simpler, as Golden wrote me a replacement for the sub using his module;
use Data::UUID::MT;
  {
    my $generator = Data::UUID::MT->new;
    sub _get_uuid {
        return lc $generator->create_string;
    }
  }


Simple or not, the problem was another: not being confident with the subject to be sure about what is what. I come from a long experience as system admin and architect, and so my approach is too conservative. I would tend to look for the root subject in any case, so to write this routine I would have started to study UUIDs, understand the landscape, to safely make the replacement.

The difference between system administration & architectures and development is:
  • In sysadmin things are good when nothing happens
  • In development things are good when something happens
I am committed to get as much as possible skills in Perl and the development practice, but I will need to change attitude to seek the solution in a more efficient way.
Sorry for the digression.

Thanks for your help.

Fabio D'Alfonso
'Enabling Business Through IT'
cell.  +39.348.059.40.22 *
web: www.fabiodalfonso.com
email: [email protected]
linkedin: www.linkedin.com/in/fabiodalfonso
twitter: www.twitter.com/#!/fabio_dalfonso

fax: +39.06.874.599.581
BlackBerry® Wireless Enabled Address.

* Hidden  numbers are automatically rejected by the phone

On 4/19/2012 5:37 AM, Sisyphus wrote:

----- Original Message ----- From: "Fabio D'Alfonso" <[email protected]>
To: "David Mertens" <[email protected]>
Cc: <[email protected]>
Sent: Wednesday, April 18, 2012 7:21 PM
Subject: Re: [Perldl] A suggestion on an old required module? Update 2


Hi,
I did not get an answer from the maintainers, yet.
Meanwhile I made some more step:

 1.. I contacted David Golden, to ask on some suggestion, and realized why

 2.. Made a deeper look at the stuff and found that, although the tree is that  ~800 objects, the module is use only in the main one, to implement this:
 #Method to generate UUIDs.
 sub _get_uuid{
     my ($uuid, $string);
     UUID::generate($uuid);
     UUID::unparse($uuid, $string);
     return $string;
 }

Can you use the following (plagiarised from Win32::Guidgen) instead of David's implementation:

###############################
use warnings;
use Win32::API;

$uuid= _get_uuid();
print $uuid;

sub _get_uuid {
   my $UuidCreate = new Win32::API('rpcrt4', 'UuidCreate', 'P', 'N');
   die 'Could not load UuidCreate from rpcrt4.dll' unless $UuidCreate;

   my $UuidToString = new Win32::API('rpcrt4', 'UuidToString', 'PP', 'N');
   die 'Could not load UuidToString from rpcrt4.dll' unless $UuidToString;

   my $RpcStringFree = new Win32::API('rpcrt4', 'RpcStringFree', 'P', 'N');
   die 'Could not load RpcStringFree from rpcrt4.dll' unless $RpcStringFree;

   my $uuid = "*" x 16; # Allocate enough space to store the uuid structure

   my $ret = $UuidCreate->Call( $uuid );
   die "UuidCreate failed with error: $ret" unless $ret == 0;

   my $ptr_str = pack("P",0);
   $ret = $UuidToString->Call( $uuid, $ptr_str );
   die "UuidToString failed with error: $ret" unless $ret == 0;

   my $guid_str = unpack( "p", $ptr_str );

   $ret = $RpcStringFree->Call( $ptr_str );
   die "RpcStringFree failed with error: $ret" unless $ret == 0;

   return '{' . uc($guid_str) . '}';
}
###############################

For me, that outputs strings like:
{AB73026A-1A00-4A0D-9734-67741D7539C1}

Is that  right ? Or does it need some adjustment ?

I could probably rewrite it as an XSub and stick it in a separate module (without too much trouble), if necessary.

Cheers,
Rob

_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to