Home > Software engineering >  Perl Win32::GuidGen format
Perl Win32::GuidGen format

Time:10-11

I have the following code

use strict;
use warnings;
use Win32;    
my $guid = Win32::GuidGen();

print $guid;

which generates GUID like this {77C71DCC-8825-4B37-A8D3-C0400C885DBB}

I am wondering if there are an option to return the guid in this format

77c71dcc-8825-4b37-a8d3-c0400c885dbb

instead of adding the following code

 $guid =~ s/^{|}$//g;
 $guid= lc($guid);

CodePudding user response:

No, Win32::GuidGen() does not have any such options.

Win32::GuidGen() simply returns the string provided by the OS.

Faster:

my $guid = lc( substr( Win32::GuidGen(), 1, -1 ) );
  •  Tags:  
  • perl
  • Related