0

I was playing with this piece of code to print a list of chars:

perl -e 'print join(" ", map { sprintf "%02x", ord }  grep /\s/, map { chr } 0x0 .. 0x7F )'

Is there a easier way to write map { chr } 0x0 .. 0x7F ?

I've tried:

map \&chr 0x0 .. 0x7F

But I get syntax error.

1 Answers1

4

map { chr } 0x00 .. 0x7F is already pretty concise, but in addition to the map BLOCK LIST syntax, there is also the map EXPR,LIST syntax.

map chr,0x00..0x7f
map chr,0..127
mob
  • 117,087
  • 18
  • 149
  • 283