stevieb has asked for the wisdom of the Perl Monks concerning the following question:
I'm looking for a method to convert newline-type characters to their octal forms. I've figured out how to get the hex representation:
perl -E 'say unpack "H*", "\r\n";'
...but I'd like to get this as "015012" as opposed to "0d0a".
I've been searching on and off today, testing with sprintf, oct and a myriad of other things, but I'm not familiar with this type of transormation (the above unpack was something unrelated I found online... I've never used or have needed to use pack before).
I'd like to point out that I'm not trying to ask "what is a better regex" or "should I use this or this" (so things like tye's Re: \r\n vs \012\015 (tye) aren't really relevant), and this isn't an XY Problem, I just am curious as to how it's done, regardless of need or use case.
-stevieb
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Transforming "\r\n" to '\012\015'
by AnomalousMonk (Archbishop) on Sep 20, 2015 at 22:11 UTC | |
|
Re: Transforming "\r\n" to '\012\015'
by LanX (Saint) on Sep 20, 2015 at 22:13 UTC | |
|
Re: Transforming "\r\n" to '\012\015'
by RichardK (Parson) on Sep 20, 2015 at 22:14 UTC | |
|
Re: Transforming "\r\n" to '\012\015' ( octal escape encode pack implode )
by Anonymous Monk on Sep 20, 2015 at 22:13 UTC | |
|
Re: Transforming "\r\n" to '\012\015'
by Laurent_R (Canon) on Sep 21, 2015 at 16:45 UTC | |
|
Re: Transforming "\r\n" to '\012\015'
by Anonymous Monk on Sep 21, 2015 at 16:40 UTC |