in reply to Something strange in the world or Regexes

Maybe something went wrong when pasting your code, because the following "hex dumper" shows me a \x20 from a line pasted:

perl -lne "printf qq([%s] => %02x\n), $_, ord $_ for split //" mmu-miR-150 [m] => 6d [m] => 6d [u] => 75 [-] => 2d [m] => 6d [i] => 69 [R] => 52 [-] => 2d [1] => 31 [5] => 35 [0] => 30 [ ] => 20

Replies are listed 'Best First'.
Re^2: Something strange in the world or Regexes
by mrguy123 (Hermit) on Sep 30, 2009 at 09:56 UTC
    It makes sense that by copying and pasting the code I got rid of the "non core" character. Can you explain what you did with the "hex dumper"?
    Thanks, mrguy

      Something I find quite helpful with one liners is B::Deparse:

      >perl -MO=Deparse -lne "printf qq([%s] => %02x\n), $_, ord $_ for spli +t //" BEGIN { $/ = "\n"; $\ = "\n"; } LINE: while (defined($_ = <ARGV>)) { chomp $_; printf "[%s] => %02x\n", $_, ord $_ foreach (split(//, $_, 0)); }

      So that program goes through the input, splits it between each byte, and then feeds each byte as a character and as the number to the printf function.