in reply to Obfuscation or printing words like \160\162\151\156\164

for (my $i=33; $i<=126; $i++) { printf("\\%o = %s\n", $i, chr($i)); }

Output:

\41 = ! \42 = " \43 = # \44 = $ \45 = % \46 = & \47 = ' \50 = ( \51 = ) \52 = * \53 = + \54 = , \55 = - \56 = . \57 = / \60 = 0 \61 = 1 \62 = 2 \63 = 3 \64 = 4 \65 = 5 \66 = 6 \67 = 7 \70 = 8 \71 = 9 \72 = : \73 = ; \74 = < \75 = = \76 = > \77 = ? \100 = @ \101 = A \102 = B \103 = C \104 = D \105 = E \106 = F \107 = G \110 = H \111 = I \112 = J \113 = K \114 = L \115 = M \116 = N \117 = O \120 = P \121 = Q \122 = R \123 = S \124 = T \125 = U \126 = V \127 = W \130 = X \131 = Y \132 = Z \133 = [ \134 = \ \135 = ] \136 = ^ \137 = _ \140 = ` \141 = a \142 = b \143 = c \144 = d \145 = e \146 = f \147 = g \150 = h \151 = i \152 = j \153 = k \154 = l \155 = m \156 = n \157 = o \160 = p \161 = q \162 = r \163 = s \164 = t \165 = u \166 = v \167 = w \170 = x \171 = y \172 = z \173 = { \174 = | \175 = } \176 = ~

There's no 108 and 109 in octal.

\40 gives character 32, the space.

Replies are listed 'Best First'.
Re^2: Obfuscation or printing words like \160\162\151\156\164
by jbrugger (Parson) on Apr 06, 2005 at 05:10 UTC
    Oké. Thanks that worked. Perhaps a stupid question, but where could i have found this in documentation?
    I've used supersearch, google, but i came across nothing.
    perhaps a bad search query...

    *** UPDATE *** Well, i made a little script to make it more easy to translate your text to create obfuscated code... Feel free to enhance and critisize, but thanks to you all for the help:
    #!/usr/bin/perl -w use strict; my $chars = {}; for (my $i=33; $i<=127; $i++) { my $oct = sprintf("\\%o", $i); $chars->{chr($i)} = $oct; } foreach my $word (@ARGV) { my(@str) = split(//,$word); foreach my $letter (@str) { print $chars->{$letter}; } print " "; } # ./obus.pl just another Perl hacker, # returns # \152\165\163\164 \141\156\157\164\150\145\162 \120\145\162\154 \150\ +141\143\153\145\162\54

    "We all agree on the necessity of compromise. We just can't agree on when it's necessary to compromise." - Larry Wall.

      String literals are documented in the section "Quote and Quote-like Operators" of perlop.

      printf format strings are documented under sprintf in perlfunc, as indicated under printf in perlfunc.

      As stated by the previous poster, the \102 \103 etc are octal codes. These can be looked up in an ascii table such as: this one.

      Also as stated, since it is octal, it is a base 8 system, meaning the numbering goes:

      000 001 002 003 004 005 006 007
      010 011 012 013 014 015 016 017
      020 021 022 023 024 025 026 027
      etc
      etc
      where could i have found this in documentation?

      Any ASCII table. And as for them not seeming to be in any order, I think it's actually quite orderly, so long as you stay in octal:

      • Uppercase : 0100 + letter position
      • Lowercase : 0140 + letter position
      • Digits : 060 + number