in reply to Using subroutine between scripts

It depends on how often you would see it used. To start with put the sub in a file called something.lib You will not need the shebang line. At the end of the file have the last line be just 1; example:
sub my_silly_sub() { print "This is a silly sub"; } 1;
And in the perl scripts that use it use
require "something.lib";
Depending on the need to use it across lots of scripts or a few, you may than want to move its location to an area common to your scripts. But I wouldn't make it a module until you find it spreading. But than again there are many opinions on what to do. Choose what is best for you.
"No matter where you go, there you are." BB

Replies are listed 'Best First'.
Re: Re: Using subroutine between scripts
by ChrisR (Hermit) on Nov 07, 2003 at 16:30 UTC
    I always use the shebang line in my libraries but it does make sense that you don't need it since the library should never be used by itself. Can you think of any problems that my arise from having the shebang in a library?
      I also often put a shebang in my libraries. It can be helpful to text editors in figuring out what kind of file it is. Emacs, for example, can infer the file type by looking at the first few characters. If I create a Perl library starting with a shebang line, Emacs will open it in Perl mode, regardless of the filename. I've been doing this for years and have never had any problems with it.

      No not really but I was just taught you don't need the shebang line so I never put it in. I personally see the shebang line as the beginning of a script so I leave it out of libraries. I would ask other monks if there are any problems with including it but I can't think of any.

      "No matter where you go, there you are." BB