in reply to Script to convert HBA WWNs to lowercase and add ":"[Updated]

++ for a handy utility

Golf anyone?

perl -E'say join":",grep$_,split/(..)/,lc"10000000C9ABCDEF"' 10:00:00:00:c9:ab:cd:ef

Replies are listed 'Best First'.
Re^2: Script to convert HBA WWNs to lowercase and add ":"
by hbm (Hermit) on Dec 17, 2011 at 18:11 UTC

    Ok. Fore!

    #perl -E'say join":",grep$_,split/(..)/,lc"10000000C9ABCDEF"' perl -E"$_=lc'10000000C9ABCDEF';s/..(?=.)\K/:/g;say" 10:00:00:00:c9:ab:cd:ef

      Nice! I learned something.

      I like to "correctly" handle the case where there may already be colons in the string.
      perl -E"$_=lc'02468ACE';s/[^:]{2}(?=[^:])\K/:/g;say" 02:46:8a:ce perl -E"$_=lc'02:46:8A:CE';s/[^:]{2}(?=[^:])\K/:/g;say" 02:46:8a:ce
Re^2: Script to convert HBA WWNs to lowercase and add ":"
by perl514 (Pilgrim) on Dec 28, 2011 at 17:52 UTC

    Hi keszler,

    Thank you for the encouragement. I have posted and updated version of the script. Kindly take a look and let me know.

    Perlpetually Indebted To PerlMonks