footer on Joel's email
[1/12] from: athiele:abraxis at: 15-Mar-2002 21:25
I can`t figure it out, can you explain?
; sub REBOL {}; sub head ($) {@_[0]}
REBOL []
# despam: func [e] [replace replace/all e ":" "." "#" "@"]
; sub despam {my ($e) = @_; $e =~ tr/:#/.@/; return "\n$e"}
print head reverse despam "moc:xedef#yleen:leoj" ;
Adrian
[2/12] from: joel::neely::fedex::com at: 15-Mar-2002 22:04
Hi, Adrian,
Copy-and-paste it into your REBOL console (if you're willing
to trust me! ;-) or into a file that you can DO from the
REBOL console. Alternately, you can run that same file in
Perl.
The goofy looking string at the end is just an anti-spam
encoding of my email address. The rest of it is decoding
script that works in both languages. I couldn't pass up
the opportunity to combine four of my favorite things:
- REBOL
- Perl
- programming puzzles
- making life harder for spammers
;-)
-jn-
Adrian wrote:
> I can`t figure it out, can you explain?
>
> ; sub REBOL {}; sub head ($) {@_[0]}
> REBOL []
> # despam: func [e] [replace replace/all e ":" "." "#" "@"]
> ; sub despam {my ($e) = @_; $e =~ tr/:#/.@/; return "\n$e"}
> print head reverse despam "moc:xedef#yleen:leoj" ;
>
--
; sub REBOL {}; sub head ($) {@_[0]}
REBOL []
# despam: func [e] [replace replace/all e ":" "." "#" "@"]
; sub despam {my ($e) = @_; $e =~ tr/:#/.@/; return "\n$e"}
print head reverse despam "moc:xedef#yleen:leoj" ;
[3/12] from: ronald:free at: 16-Mar-2002 8:55
Bonjour Adrian,
Saturday, March 16, 2002, 3:25:50 AM, vous avez écrit:
A> I can`t figure it out, can you explain?
A> ; sub REBOL {}; sub head ($) {@_[0]}
A> REBOL []
A> # despam: func [e] [replace replace/all e ":" "." "#" "@"]
A> ; sub despam {my ($e) = @_; $e =~ tr/:#/.@/; return "\n$e"}
A> print head reverse despam "moc:xedef#yleen:leoj" ;
A> Adrian
Hi Adrian,
copy paste the code and add halt at the end (in order to see the
result) and run it...
Cheers
--
Ronald
[4/12] from: chalz:earthlink at: 18-Mar-2002 1:33
> Hi, Adrian,
>
> Copy-and-paste it into your REBOL console (if you're willing
> to trust me! ;-) or into a file that you can DO from the
> REBOL console. Alternately, you can run that same file in
> Perl.
Oh. The mystery commented portion is Perl... that makes sense, now. Hmm...
Little question, though. WTF does # do, precisely? It appears to be a comment
character for Perl (yes?), but when I try to help or source it, I get told it's
an issue. But I can do "# print "hi"" and it prints "hi" okay. Help?
--Charles
[5/12] from: hallvard:ystad:helpinhand at: 18-Mar-2002 13:40
Dixit Charles (07.33 18.03.2002):
> Oh. The mystery commented portion is Perl... that makes sense, now. Hmm...
>Little question, though. WTF does # do, precisely? It appears to be a comment
>character for Perl (yes?), but when I try to help or source it, I get told it's
>an issue. But I can do "# print "hi"" and it prints "hi" okay. Help?
You can do # because # is an issue, and do # simply returns #: Here's from the console:
>> trace on
Result: (unset)
>> do #
Trace: do (word)
Trace: # (issue)
Result: # (issue)
== #
So # print "hi" prints hi because # doesn't print anything. You could equally do "Here's
a string" print "hi", which also simply prints "hi":
>> "Here's a string" print "hi"
Trace: "Here's a string" (string)
Trace: print (word)
Trace: "hi" (string)
hi
Result: (unset)
~H
[6/12] from: gscottjones:mchsi at: 18-Mar-2002 7:40
From: "Charles"
To: <[rebol-list--rebol--com]>
Sent: Monday, March 18, 2002 12:33 AM
Subject: [REBOL] Re: footer on Joel's email
...
> Oh. The mystery commented portion is Perl... that makes sense,
> now. Hmm... Little question, though. WTF does # do, precisely?
> It appears to be a comment character for Perl (yes?), but when I
try to help or source it, I get told it's an issue. But I can do
# print
hi"" and it prints "hi" okay. Help?
...
Hi, Charles,
I'm not expert in PERL (in fact I'm not even a rank amature), but
if I recall correctly, here is a blow by blow interpretation for
anyone else who may be curious about other details:
line1 ; sub REBOL {}; sub head ($) {@_[0]}
line2 REBOL []
line3 # despam: func [e] [replace replace/all e ":" "." "#" "@"]
line4 ; sub despam {my ($e) = @_; $e =~ tr/:#/.@/; return "\n$e"}
line5 print head reverse despam "moc:xedef#yleen:leoj" ;
line1
defines 2 subroutines in PERL. This line appears as a
comment to REBOL. The fist part is a do-nothing call. The
second, I believe, simply returns the string that was passed as
a parameter.
line2
is the REBOL header. PERL will see this as a subroutine
call, as is defined in "line1".
line3
is a function definition in REBOL. This line appears as
a comment to PERL.
line4
is a subroutine definition in PERL. This line appears as
a comment to REBOL. line3 and line4 offer similar functionality
for the two different languages in terms of "despamming" the
semi-obfuscated email address.
line5
calls the language-dependent versions of the
functions/subroutines. "print" and "reverse" are shared between
the lanuguages.
This is very clever cross platform, cross language programming.
2 languages down; 10^12 to go, Joel!
>From REBOL Core User's Guide:
Issues are identification numbers, such as telephone
numbers, model numbers, credit card numbers.
For example:
#707-467-8000
#0000-1234-5678-9999
#MFG-932-741-A
In Joel's program, an empty issue identifier is simply passed on
without action or assignment.
Clear as mud?
--Scott Jones
[7/12] from: joel:neely:fedex at: 18-Mar-2002 8:05
Hi, Charles,
OK, here are my deep dark secrets...
Charles wrote:
> Oh. The mystery commented portion is Perl... that makes sense,
> now. Hmm...
>
The point of the sig is to allow someone to discover my email
address without placing it in clear text, thus making it just
a little harder for spamvultures to harvest it from the plain
text of the email message. The email address (string) is
reversed, with the . and @ replaced with other characters.
That way a spamvulturebot that is looking for strings that
contain dots and at-signs would not pick up that line as an
encoded email address.
Here's an explanation of the sig, line by line:
; sub REBOL {}; sub head ($) {@_[0]}
Semicolon is the REBOL comment prefix (thru end of line);
this line contains Perl code to define:
- a null function named REBOL (to ignore the header);
- a function named "head" that returns its argument (this
will be explained below).
Since the REBOL interpreter is supposed to ignore everything
above the header I didn't actually need the semicolon. I left
it there as a hint, since I *do* need comment-escaped code
later on. An experienced REBOL programmer would know that it
wasn't needed, so that would draw attention to the question,
"Why did he make that a comment?" and provide a clue about the
use of language-specific commenting.
REBOL []
The REBOL header, to engage the REBOL interpreter. I needed
the null function "REBOL" in Perl to make this line legal in
both languages. The argument is an empty block to REBOL, but
is an anonymous array reference to Perl (which will silently
ignore it, due to the definition of the null function).
# despam: func [e] [replace replace/all e ":" "." "#" "@"]
This one is a tad obscure! ;-) I need functions to fix the
./: and @/# substitutions in both languages. Each of these
functions needs to be hidden from the other language (in the
simplest/shortest way possible). The octothorp/hash/pound
is the single-line comment prefix in Perl, just as ; is to
REBOL, *but* in REBOL it marks the beginning of an ISSUE!
data value (in this case, a zero-length one! ;-)
>> print #1234
1234
>> print #
>> type? #
== issue!
>> length? #
== 0
REBOL silently ignores expressions or simple values which
appear "between expressions" (i.e., without being used to
set a word's value, as function arguments, etc...) as long
as they have no side-effects. Thus I can begin the line
with a comment marker to make Perl ignore this line, but
it looks to REBOL like an extra trivial value that can be
ignored.
The rest of the line simply defines the DESPAM function to
REBOL as handling the punctuation (de)substitution.
; sub despam {my ($e) = @_; $e =~ tr/:#/.@/; return "\n$e"}
This is the Perlish version of the previous line. The
semicolon hides this line from REBOL. Semicolons are
used in Perl to separate statements/expressions, so this
just looks to Perl like an empty expression followed by
a function definition. There's one additional trick in
this function; the REBOL native PRINT puts a newline at
the end of what's displayed to the console. Perl doesn't
do that; it let's the script decide when/where to put in
line breaks. Therefore, the Perl "despam" function has
to put a newline at the *beginning* of its result (since
the result will be reversed before printing ;-).
print head reverse despam "moc:xedef#yleen:leoj" ;
Now I have all the functions I need in both Perl and REBOL;
both languages have "print" and "reverse" functions, and I've
defined "head" for Perl. The gimmick is that REBOL returns
a reversed series at its tail, but Perl returns a reversed
string at its beginning. Therefore I needed "head" for
REBOL, but the Perl version didn't need to do anything.
Lots of work for a five-line sig, but it was fun to get all of
the puzzle pieces lined up just right...
-jn-
--
; Joel Neely joeldotneelyatfedexdotcom
REBOL [] do [ do func [s] [ foreach [a b] s [prin b] ] sort/skip
do function [s] [t] [ t: "" foreach [a b] s [repend t [b a]] t ] {
| e s m!zauafBpcvekexEohthjJakwLrngohOqrlryRnsctdtiub} 2 ]
[8/12] from: chalz:earthlink at: 18-Mar-2002 22:57
> Since the REBOL interpreter is supposed to ignore everything
> above the header I didn't actually need the semicolon. I left
<<quoted lines omitted: 3>>
> "Why did he make that a comment?" and provide a clue about the
> use of language-specific commenting.
There is, of course, the point that if one were to copy&paste the sig into
the console (which is what I did), then the comment /is/ required, and the
REBOL [] does nothing special.
> REBOL []
>
> The REBOL header, to engage the REBOL interpreter. I needed
> the null function "REBOL" in Perl to make this line legal in
> both languages. The argument is an empty block to REBOL, but
> is an anonymous array reference to Perl (which will silently
> ignore it, due to the definition of the null function).
Again, if you just copy&paste in the interpreter, this isn't even necessary.
> # despam: func [e] [replace replace/all e ":" "." "#" "@"]
>
> This one is a tad obscure! ;-) I need functions to fix the
> ./: and @/# substitutions in both languages. Each of these
> functions needs to be hidden from the other language (in the
> simplest/shortest way possible). The octothorp/hash/pound
"octothorp"? I've never heard that term before! Ah, but Merriam-Webster
( http://www.m-w.com ) says:
Main Entry: oc·to·thorp
Pronunciation: 'äk-t&-"thorp, -tO-
Function: noun
Etymology: octo- + thorp, of unknown origin; from the eight points on its
circumference
Date: 1971
: the symbol #
Fascinating!!
> print head reverse despam "moc:xedef#yleen:leoj" ;
I find that line to be particularly clever myself. A single line of code
that works equally well in 2 separate languages. Ah, perhaps this could be the
standard upon which to evaluate other languages? ;)
> Lots of work for a five-line sig, but it was fun to get all of
> the puzzle pieces lined up just right...
Kind of like an engineer creating a vastly complex system to solve a simple
problem, simply because it's a fun thought project. Heh.
> ; Joel Neely joeldotneelyatfedexdotcom
> REBOL [] do [ do func [s] [ foreach [a b] s [prin b] ] sort/skip
> do function [s] [t] [ t: "" foreach [a b] s [repend t [b a]] t ] {
> | e s m!zauafBpcvekexEohthjJakwLrngohOqrlryRnsctdtiub} 2 ]
A new one.... hmmm.. You need serious help, you know that? Egads. I
wonder if the unused letters spell something... But how to decipher it?...
*laughs*
--Charles
[9/12] from: chalz:earthlink at: 18-Mar-2002 22:41
<snipsnip>
> In Joel's program, an empty issue identifier is simply passed on
> without action or assignment.
>
> Clear as mud?
>
> --Scott Jones
Once I thought about it, it occurred to me what was going on. REBOL would
just output the last evaluation anyways. Such as:
>> a: 5 "hi"
== "hi"
or
>> "" "hi"
== "hi"
Since # doesn't do anything, it's all good to include it. Pretty spiffy.
Of course, if you try:
>> $ "hi"
You end up with "Syntax Error: Invalid money -- $". I'm sort of curious why
it doesn't give you "Invalid issue", then, but that's for another topic ;)
Thanks guys.
--Charles
[10/12] from: joel:neely:fedex at: 19-Mar-2002 6:10
Hi, Charles,
Charles wrote:
> There is, of course, the point that if one were to copy
> & paste the sig into the console (which is what I did),
> then the comment /is/ required, and the REBOL [] does
> nothing special.
>
And a good point it is, too!
> "octothorp"? I've never heard that term before! Ah, but
> Merriam-Webster
<<quoted lines omitted: 8>>
> Fascinating!!
>From _The_Elements_of_Typographic_Style_ by Robert Bringhurst,
a standard refererence in the field of typography...
octothorp Otherwise known a the numeral sign. It
has also been used as a symbol for the
pound avoirdupois, but this usage is now archaic.
In cartography, it is also a symbol for a village:
eight fields around a central square, and this is
the source of its name. Octothorp means eight fields.
Of course this also means that REBOL is eight times better
than c# ("see octothorp") and has it completely surrounded.
--
; Joel Neely joeldotneelyatfedexdotcom
REBOL [] do [ do func [s] [ foreach [a b] s [prin b] ] sort/skip
do function [s] [t] [ t: "" foreach [a b] s [repend t [b a]] t ] {
| e s m!zauafBpcvekexEohthjJakwLrngohOqrlryRnsctdtiub} 2 ]
[11/12] from: chalz:earthlink at: 20-Mar-2002 0:03
> From _The_Elements_of_Typographic_Style_ by Robert Bringhurst,
> a standard refererence in the field of typography...
I thought typography was the study of errors during typing. Hmm... ;)
> octothorp Otherwise known a the numeral sign. It
> has also been used as a symbol for the
<<quoted lines omitted: 4>>
> Of course this also means that REBOL is eight times better
> than c# ("see octothorp") and has it completely surrounded.
And, well, there's always the musical notation, in which # refers to a
'sharp' note, such as C# is C-sharp, or a half-step between C and D (not
looking for debates on whether or not it really /is/ half way in between or
not - it's close enough).
[12/12] from: joel:neely:fedex at: 20-Mar-2002 8:58
Hi, Charles,
Charles wrote:
> Since # doesn't do anything, it's all good to include it.
> Pretty spiffy. Of course, if you try:
> >> $ "hi"
> You end up with "Syntax Error: Invalid money -- $". I'm
> sort of curious why it doesn't give you "Invalid issue"...
>
There's a short answer; an issue is a kind of series (of the
any-string! variety). It's perfectly legal for a string (or
any other series flavor) to have a length of zero, as in
""
{}
[]
or
#
but it's not syntactically valid to have a number which
contains no digits.
-jn-
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted