Re: Perl

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

From: Juerd
Subject: Re: Perl
Date: 11:38 on 25 Feb 2004
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.

Perl is case sensitive. Your hate should be directed at your filesystem,
which is not case sensitive. Perl expects a case sensitive filesystem,
and does not do anything special with case insensitive ones. Mostly
because it is hard to know what you're dealing with.

If you named your module Foo by having "package Foo;" in it and saving
it as "Foo.pm", you have to "use Foo;" to make it work.

In that situation, when you "use foo;", perl loads "foo.pm" (which isn't
supposed to work!) and then tries "foo->import", but only if
foo->can('import'). But foo does not have a method "import". Foo has,
but Foo's import is never used.

Perl cannot easily determine if your filesystem is retarded.

Perl cannot warn you about a missing import(), because that method is
optional.

Perl does not warn when the package isn't equal to the filename, because
it would lose a great deal of flexibility.

So either hate your stupid case insensitive filesystem. Alternatively,
use a less flexible programming language.

> it just whines that it can't find &main::foo() when it's supposed
> to be getting &thing::foo().

It isn't.

When you "use Foo;", Foo->import is called. That method, when called
from main:: and made to export a symbol "bar", eventually does this:

    *main::bar = *Foo::bar;

Your calls to "bar()" aren't magically converted to "Foo::bar()".

> ... is completely not acceptable to me.

Then why even use Perl?

> open(FILE,"<somefile");

open my $fh, '<', 'somefile' or die "Could not open somefile: $!\n";

You're *ASKING* for troubly by using a global filehandle and not
checking open's return value (unless you use Fatal, but I doubt you do).


Juerd
There's stuff above here

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