Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Obfuscation or printing words like \160\162\151\156\164

by Tanktalus (Canon)
on Apr 06, 2005 at 15:02 UTC ( [id://445327]=note: print w/replies, xml ) Need Help??


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

So far, everyone has described the "enlightened" way to do this. As in, they read your question, and came to the conclusion that you asked "how do I do X using Y?" and so they were telling you how to do X using X.

I'll go the other route this time. Let's say I haven't been enlightened (for whatever reason, the thought that these were octal didn't occur to me until it was pointed out, so we're not far from the truth here ;->). I would do the following:

use strict; for my $i (101 .. 200) { my $a = '\\' . $i; my $val = eval qq{"$a"} || $@; print "$i = $val\n"; }
This answers your question on how to get perl to write out all the characters for you. But it does seem a bit funny. So I'd go the next step:
use strict; my %data; for my $i (101 .. 200) { my $a = '\\' . $i; my $val = eval qq{"$a"} || $@; #print "$i = $val\n"; $data{$i} = $val; } use Data::Dumper; $Data::Dumper::Sortkeys = sub { [ sort { $a <=> $b } keys %{+shift} ] }; $Data::Dumper::Useqq = 1; print Dumper(\%data);
Now we're getting somewhere interesting. For example, I see that "199 => "\00199"," appears. And yet, I also see "177 => "\177",". At this point, I'd look up the documentation and, hopefully, find out what this really means, as is described by everyone else.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://445327]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-04-26 07:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found