Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Multiple Files, One Script Possible?

by papidave (Monk)
on Feb 28, 2008 at 19:58 UTC ( #670998=note: print w/ replies, xml ) Need Help??


in reply to Multiple Files, One Script Possible?

I think that the confusion here is that inclusion of a file is generally tied closely to the specification of a separate package namespace. This is a good idea (to avoid collisions between variable and subroutine names), but isn't really required. Consider program foo.pl:

#!/usr/bin/perl -w use strict; use lib '.'; use Inc1; use Inc2; print "Here we go!\n"; foo1(); foo2(); print "All done.\n";

If modules Inc1.pm is specified as:

# first include file sub foo1 { print( "This is a test from foo1.\n" ); } 1;

and Inc2.pm is:

# second include file sub foo2 { print( "This is a test from foo2.\n" ); } 1;

You get the expected results -- that subroutines foo1 and foo2 are called from their corresponding modules.

Unlike (for example) Pascal, the Perl programmer is not burdened with the arbitrary preferences of the person who specified the language. TMTOWTDI. This is not merely a slogan, it's a language reality, and you have hereby been provided with more than enough rope to hang yourself. Use it in good health.


Comment on Re: Multiple Files, One Script Possible?
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://670998]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2014-12-29 06:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (185 votes), past polls