in reply to splitting a source file

I don't think kd is talking about creating a "module", but just simply separting his subroutines from his main code block. All you need to do is put the subroutines in a separate file, say 'subs.pl', and just do
require "subs.pl";
Once you figure out separting routines from primary code, then you can move on to writing your own modules, packages and so forth, kd. Hope this helps.

Update: And, almut and chromatic caught my mistake on using 'use', which was incorrect. I was mistaken and it should be the following to get compile time inclusion:

BEGIN { do "subs.pl"; }
Thanks for the catch, guys.

Replies are listed 'Best First'.
Re^2: splitting a source file
by chromatic (Archbishop) on Oct 24, 2007 at 19:55 UTC
    use "subs.pl";

    Did you try it?

    #!/usr/bin/perl use strict; use warnings; use "subs.pl"; foo(); bar(); syntax error at use_subs.pl line 6, near "use "subs.pl"" Execution of use_subs.pl aborted due to compilation errors. #!/usr/bin/perl use strict; use warnings; use subs.pl; foo(); bar(); syntax error at use_subs.pl line 6, near "use subs." Execution of use_subs.pl aborted due to compilation errors.
      I'm having problems running your example on my Vista desktop. Is there anything special I need or is there a bug in your example?

        The bug was the point; use doesn't work that way. That's why I think use with a real module is simpler.

Re^2: splitting a source file
by almut (Canon) on Oct 24, 2007 at 19:51 UTC
    use "subs.pl";

    ... or,

    require "subs.pl";

    Actually, it must be require "subs.pl"; or do "subs.pl";  —  use "subs.pl"; is a syntax error...   </nitpick>

    (To get the compile-time effect, you can wrap the require in a BEGIN { ... } block.)