Generate GUID in PERL

It’s very common for developer to generate a GUID in code to guarantee uniqueness. Here is the sample code to generate a GUID in Perl

my $guid = `uuidgen.exe`;
chomp $guid;

Uuuidgen.exe is a tool from DotNet Framework. You can append "-c" option to generate uppercase letters

Run uuidgen /? to see the detail usage of uuidgen.
Microsoft UUID Generator v1.01 Copyright (c) Microsoft Corporation. All rights reserved.

usage: uuidgen [-xisconvh?]
        x – Generate sequential (V1) UUIDs
        i – Output UUID in an IDL interface template
        s – Output UUID as an initialized C struct
        c – Output UUID in upper case
        o<filename> – redirect output to a file, specified immediately after o
        n<number> – Number of UUIDs to generate, specified immediately after n
        v – display version information about uuidgen
        h,? – Display command option summary

Comments

9 responses to “Generate GUID in PERL”

Leave a Reply