On Sat, 11 Mar 2000 00:58:39 -0500, Paul N. Schatz wrote: > I want to put a subroutine in a library which I create. I create a >file 'ill.pm' which I put in a folder named 'myMacPerl_library'. The file >'ill.pm' contains: >package ill; >sub say_hello { > print "hello world!\n"; >} As Ronald Kimball said: loading a library should end with the exectution of a statement evaluating to true. a sub declaration won't do. Adding "1;" as a last line is the usual way of doing it. > I add the path to the folder 'myMacPerl_library' to the paths to >search for library modules. > > I then try to access 'say_hello()' from a new Perl script. It >should be easy, but I can't seem to do it. I tried a number of things >without success. For example, > >'use myMacPerl_library::ill();' Wrong. With MyMacPerl_library added to @INC, and with "package ill;" in your library, you really should be using: use ill; Note that, with the package declaration, you need to call the function as ill::say_hello(); (Well, actually, it will work without the parentheses.) If you want to use a plain "say_hello", either drop the "package ill;" line, or provide an import() mechanism. The latter is actually rather complicated. Using Exporter might be the simplest option, although IMO it is still more complex than it should have been. This is straight from the docs of Exporter: package ill; require Exporter; @ISA = qw(Exporter); @EXPORT = qw(say_hello); # symbols to export by default ... p.s. as Ronald Kimbal also said: for module names, by convention, all lowercase names are reserved for "pragma"'s, like "use strict;" and "use integer;". Ordinary home-brewn module names should start with an uppercase letter. package Ill; and use Ill; -- Bart. # ===== Want to unsubscribe from this list? # ===== Send mail with body "unsubscribe" to macperl-request@macperl.org