$str = "ab\rcd\nef\ngh\fij"; $str =~ s{ ([^[:print:]]) }{ sprintf( "(%#2X)", ord $1) }gex;
----> ab(0XD)cd(0XA)ef(0XA)gh(0XC)ij On Tue, Sep 6, 2016 at 9:11 AM, Matt <matt.mailingli...@gmail.com> wrote: > I am receiving log entries as a string and then writing them to a file > with the date tacked on beginning. Problem is that sometimes the > string I receive contains \n and it makes parsing the file with grep > more difficult. Looking for a simple way to replace all \n in the > string with text <CR> or something of that sort. > > It might be even better yet to replace all characters that are not > directly printable with there HEX equivalent since I only need > readable text log info on one line. Is there an easy way to do that? > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/