in reply to Re^3: How to split, join and trim leading / leading white space
in thread How to split, join and trim leading / trailing white space
say join(" ", split /(..)/, "e58c97e4bab0") =~ s/^\s+//r =~ y/ / /rs;Augh! No! split /(..)/ makes a list with empty strings in it that you don't want. Those result in extra spaces when you join, which you then have to mop up with silly regexes. Use one of these instead:
say join(" ", "e58c97e4bab0" =~ /(..)/g); say join(" ", unpack "(a2)*", "e58c97e4bab0");
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: How to split, join and trim leading / leading white space
by kcott (Archbishop) on Sep 07, 2017 at 06:15 UTC | |
|