0

could someone please assist me with reversing the DN of a certificate. (I have never used perl before so I don't know what the best practices are).

I have the following string:

$issuer = "DC=ORG,DC=OpenXPKI,OU=Test CA,CN=CA ONE";

And I would need this:

$issuer = "CN=CA ONE,OU=Test CA,DC=OpenXPKI,DC=ORG";
wake-0
  • 3,918
  • 5
  • 28
  • 45

1 Answers1

4

I'd do it like this:

$issuer = join ",", reverse split (/,/, $issuer);

split your string on commas, reverse the ordering, and then join them back together (with commas)

Sobrique
  • 52,974
  • 7
  • 60
  • 101