Re: Perl

[prev] [thread] [next] [lurker] [Date index for 2004/02/25]

From: Matt McLeod
Subject: Re: Perl
Date: 12:44 on 25 Feb 2004
Juerd wrote:
> Matt McLeod skribis 2004-02-25 22:25 (+1100):
> > in the arse.  One exciting feature I came across recently is that
> > under certain circumstances you can create what seems like a module
> > which exports a bunch of names, but if you don't start the name with
> > an upper-case character it only exports the first.  And it won't
> > *tell* you this is what is going on (even with -w and use strict),
> 
> No, the name has to be equal to whatever you named your module.

Which it was.  And no, so far as I am aware the UFS implementation
on Digital UNIX is not case-smashing.

I had, in "foo.pm":

package foo;
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(bar baz quux);

sub bar { ... };
sub baz { ... };
sub quux { ... };

and then in "test.pl":

use strict;
use foo;

...


bar(...);
baz(...);


which resulted in:

Undefined subroutine &main::baz called at test.pl line 8.

You'll note that it was perfectly happy with calling foo::bar.

Change the package name to "Foo" and the filename to "Foo.pm"
after discussing it with someone else who had a vague recollection
that at some point a rule was laid down about package names, and
magically it works.

The most sensible advice I've heard with respect to this stuff is
to simply never use the Exporter thing, and always explicitly
specify where the function is coming from in every call.  Which
rather grates, but seems to work.

Now, maybe this is all down to some wacko interaction between
the particular versions of Perl and Digital UNIX involved.  But
it was bloody frustrating to deal with.  Even if that is so,
it still doesn't make up for the other irritating "features" of
the language.

> > ... is completely not acceptable to me.
> 
> Then why even use Perl?

Because I have no choice in the matter.  It's a fine tool for
doing text-parsing, not so great for other jobs, but it's usefulness
in the former has made it ubiquitous and thus rather difficult to avoid.

Damn, I'd almost rather be using COBOL.  Almost.

Matt
(who once hacked COBOL for the Mormons.)

-- 
          "The only secure Unix system is one with the power turned off."
There's stuff above here

Generated at 14:02 on 01 Jul 2004 by mariachi 0.52