Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

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

by hbm (Hermit)
on Dec 17, 2011 at 18:11 UTC ( #944097=note: print w/replies, xml ) Need Help??


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

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

Replies are listed 'Best First'.
Re^3: Script to convert HBA WWNs to lowercase and add ":"
by keszler (Priest) on Dec 17, 2011 at 22:40 UTC

    Nice! I learned something.

Re^3: Script to convert HBA WWNs to lowercase and add ":"
by samwyse (Scribe) on Jan 18, 2012 at 17:34 UTC
    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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://944097]
help
Chatterbox?
[usemodperl]: question
[usemodperl]: perldoc -v 'ARGV' works but perldoc -v "STDIN' does not, but they are both filehandles. is there a perldoc for STDIN?
[usemodperl]: (typo not withstanding :)
usemodperl thinks about loose coupling...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2018-06-19 19:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (114 votes). Check out past polls.

    Notices?