cons-discuss
[Top][All Lists]
Advanced

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

Packages and cons


From: Gary Oberbrunner
Subject: Packages and cons
Date: Tue, 17 Jul 2001 16:20:09 -0400

I'm not a perl package expert.  I'm getting a bit confused about the various
packages used by cons, and where I should put things.

Let's say I'd like to define a set of useful subroutines in cons-subs.pl,
and 'require' them into my Construct so that all Conscripts can use them
without doing anything further.  Is that possible?  Here's what I've tried:

Force every Conscript to do 'require Cons-subs.pl' at the top.  This works
but requires modifying all the Conscripts.

In Cons-subs.pl, do 'package main' and then in the Conscripts call the
functions like ::get_date().  The extra colons seem superfluous, but I don't
know how to get rid of them.

Make Cons-subs.pl into a Perl Module (ConsSubs.pm), export all the desired
methods, then in Construct write 'use ConsSubs;'.  I thought this would
propagate to the Conscripts, but it doesn't, I guess because those imports
get cleaned from the script package after reading Construct.  So I'm back to
having to include a line in each Conscript.



So here's my question for you: Is there any way to define functions in the
top-level Construct (or a file require'd by it) in such a way that they can
be used in all Conscripts without package qualifiers?  Or would this just be
a Bad Idea (tm)?

thanks all,

. . . . . . . . . . . . . . . . . . . . . . . . .
Gary Oberbrunner                address@hidden
GenArts, Inc.                   Tel: 617-492-2888
8 Clinton Street                Fax: 617-492-2852
Cambridge, MA 02139 USA         http://web.genarts.com




reply via email to

[Prev in Thread] Current Thread [Next in Thread]