Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Proper way to create packages and re-usable code?

by apadamson (Initiate)
on Feb 11, 2016 at 08:24 UTC ( [id://1154923]=note: print w/replies, xml ) Need Help??


in reply to Proper way to create packages and re-usable code?

Hello, I think you have to distinguish in your mind between having a multi source-file program (as you would often do in C) and writing a library of functions (as in libc). If you can imagine your routines as in a library, then can put them quite easily into a Perl module. The point is that library routines are self-contained. You don't, for example, consider printf as part of your program; it is just a library routine you use. In Perl, this is a potential problem with the scope of objects as variables in a module are not local to that module! You can also use "our" to make them very visible. I don't know if this helps but I have written several modules because I believe in re-usable code.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-03-29 02:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found