Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Script to convert HBA WWNs to lowercase and add ":"

by keszler (Priest)
on Dec 17, 2011 at 17:05 UTC ( #944093=note: print w/ replies, xml ) Need Help??


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


Comment on Re: Script to convert HBA WWNs to lowercase and add ":"
Download Code
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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://944093]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (12)
As of 2014-12-26 18:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (174 votes), past polls