[Tutor] Article/Code/Python vs. Rebol [defending Perl]

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Thu Jan 23 17:58:14 2003


[warning: I'm defending Perl in this article.  Skip if you have a weak
stomach for typeglobs.  *grin*]


On Thu, 23 Jan 2003, Tim Johnson wrote:

> Hello All: I've written two "columns" for a local 'webzine':
> It's at
>   http://www.frozen-north-linuxonline.com/
>
>   One column is on mailing lists and my part of
>   it is under "Tim's Byte's".
>
>   Python (and rebol) is mentioned there.

Hi Tim,

Small corrections: the Perl version of the code needs to make sure '$Var2'
is capitalized.  This is actually more serious than it looks because if we
don't 'use strict', Perl will blissfully use 'undef' as a value for
'$VAR2'.  Also, the Perl code needs to run in a loop to match the behavior
of the Rebol and Python code.


I have to take exception on the comment:

""" According to the perl programmers that submitted the code, this really
can't be done in perl. The best that can be done is an anonymous'
function.  But this is not meant to "show up" perl.  Rebol really sucks at
regular expressions and regular expressins are perl's forte. We really
should do a Code Corner on regular expressions """


This is not correct at all: there IS a perfectly good way to do it in
Perl.

###
use strict;

for my $i(1..5) {
    $main::{"h$i"} = sub {
	$_ = shift @_;
	print("<h$i>$_</hi>");
    };
}

h1("hello");
h2("world");
###

It's ugly, but it does work.  Whoever you talked to about Perl may need to
review their material.  *cough*

Language comparisons are interesting, but not useful if they misrepresent
the languages they compare.  If you do more langauge comparisons involving
Perl, make sure you talk to folks like the people from perlmonks.

    http://perlmonks.com/


Ok, enough Perl apologizing; back to Python.  *grin* Hope this helps!