Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Splitting program into modules

by harangzsolt33 (Chaplain)
on Nov 11, 2018 at 03:50 UTC ( [id://1225557]=note: print w/replies, xml ) Need Help??


in reply to Splitting program into modules

I have written a little sub that includes other files in your perl code. And I think, it's exactly what you need. Just try it and see if it works:

include('database.pl');

OR

my $whatever = include('getTime.pl');

...

sub include{open my$H,'<:raw',$_[0];read($H,my$E,999999)or die"Error: Can't include \"$_[0]\"";close$H;eval$E;}

Replies are listed 'Best First'.
Re^2: Splitting program into modules
by Corion (Patriarch) on Nov 11, 2018 at 07:29 UTC

    Can you tell us how your code improves over do and require?

    Also, please note the limitations of your code, like that it doesn't handle files larger than a megabyte.

      Oh, yes, there seems to be no difference between include() and require. I haven't thought of that! :/
        > no difference between include() and require

        Actually you reimplemented do

        require is basically a do that searches through @INC and accepts module::names.

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-04-25 15:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found