[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] 5.1.4 notes




I haven't installed 5.1.4b1 yet so I can't help with that, but can with
a couple of other things Danny's seeing.

|2) [not new with 5.1.4] how should I use StandardFile
I think your usage is correct, StandardFile just hasn't been fixed
to give no warnings under use strict. You can either ignore the
warnings, or make Matthias happy and fix the problem and send him
the patch. :-)

|4a) [...] 5.1.4 says that
|   %f = {};
|hash has an odd number of elements. So changing that to
|   %f = ();
|seemed to quieten it down. Can someone explain this?

Curly brackets are used to construct anonymous hashes. Their result is
a reference to that hash. So with %f = {} you're trying to assign a
reference (one item) to a hash. However, hashes are initialized with
lists which must have an even number of elements. Hence the warning.
The proper way to initialize an empty hash is with an empty list, which
is why %f = () works.

In fact, in the first case you weren't getting an empty hash before,
you were getting a hash with one element, the key being the stringified
version of the reference and the value being empty.

You could also say $f = {}. Now you're assigning a reference to a scalar,
which is just fine. Then you'd reference the entire hash with %$f, and
elements with $f->{'key'}, etc.

|4b) how should I use the Exporter module?
Your usage is basically correct. The warnings you're seeing have nothing
to do with OO or packages, they're caused by use strict. I suggest you
read the appropriate pod or manual page for all the details on use strict,
but a couple of things you can't do under use strict are use a variable
without declaring it, and use a bareword. Thus:

|  @ISA = Exporter;
|  @EXPORT = qw(...);

should be either

use vars qw(@ISA, @EXPORT);
@ISA = qw(Exporter);
@EXPORT = qw(...);

or

@main::ISA = qw(Exporter);
@main::EXPORT = qw(...);

Brian

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch