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

Re: [MacPerl] Problem w/making runtime version of script



At 10:42 AM -0600 8/9/99, Brenda Cannon wrote:
>I have the following snippet of code at the beginning of one of my
>scripts:
>
>#!/usr/local/bin/perl -w
>#use strict
>
>use constant FALSE => 0;
>use constant TRUE => 1;
>
>use Getopt::Long;
>use Config;
>
>require "shellwords.pl";
>require "GUSI.ph";
>
>
>The problem is that when I actually tried making a runtime version of
>this script it saved it with no errors/warnings, but then when I
>actually try to run it on the other machine I get the error that it
>cannot locate constant.pm in @INC.  Can anyone tell me what is going on
>here?

The statement

	use constant whatever

is not Perl.  :-)

As the Camel says: "The use declaration imports some semantics into 
the current package from the named module..."

So Perl expects a module named 'constant' (constant.pm, really). You 
got no warnings because it's plausible that there would be such a 
module. Only when the script executes would it actually not find the 
module constant.pm.

What can be confusing here is that there is a Perl Standard Library 
module called 'vars' whose purpose is to pre-declare names for global 
variables, so you see statements like

	use vars '$a', '@blah', '%doodah';    # OK.
	use vars qw($a @blah %doodah);        # Same, easier to type.

Because it's part of the Standard Library, it's in virtually every 
Perl installation.

On a related topic: it looks like what you're doing is setting true & 
false variables or constants, and that's not the way it works in Perl 
either ... :-)

With a little more code to give context, it might be possible to 
suggest a better way to do it.

Meanwhile, if you can, read Perl references on "truth."

What's true in Perl:
	any string except "" or "0" [zero]
	any number except 0
	any reference.
 
What's false in Perl:
	the strings "" and "0" [zero]
	the number 0
	any value that is undefined.

What this means is that truth can be tested on anything along the way 
in your program.

HTH

1;




- Bruce

__Bruce_Van_Allen___bva@cruzio.com__831_429_1688_V__
__PO_Box_839__Santa_Cruz_CA__95061__831_426_2474_W__


===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org