Chris Rogers wrote: > Just create a separate file to hold your "library" routines. You may name > the file anything you like. Be sure to put the line: >
Good advice. It is a good idea to use a .pm extension, and to have a package name identical to the base name: file: rjnWeb.pm in script: package rjnWeb; some Perl installations are very picky about packages being labeled. > > #!/usr/bin/perl > > at the top of the file (changing it to match where your version of perl is > installed). I also put a: > > 1; > > on the next line [RJN--see comment below] to keep perl from bombing out(this may not > be necessary for > you but it was for me). Then just put all your subroutines in the new file: Putting the true return value immediately after the headers and the package label command will work, because encapsulated code is not read in the main body of the script, thereofre the last line of script comes before the function definitions. It could make it harder for others when you share your code though, as the convention is to put the true return value as the last line of code, like so: 1; __END__ Also note, that this need not be the number one. The perl interpreter expects its reading of the module to return a true value. This can be anything other than 0 or undef. For instance: "Geeks rule!"; __END__ would do just as well. > sub MySub > { > ...(code here) > } > sub MySub2{ > { > ...(code here) > } > > The last step is to put a "require" statement in your perl program so that > it knows where to find the "library" or subroutines. This line looks like Read around in the archives. You will find numerous explanations of why the use function generally works better. It will call the require function anyway, as well as providing a greater transparency. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]