Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

okay. i've been around the globe, not literally, trying to figure this module thing out. I have a basic understanding. I have been coding in perl for years, and modules have always confused me somewhat, cuz they don't seem to behave like .H files in C or .TPU files in pascal - their equivalent to .PM files.

anyway, i went to stackexchange to ask my question - what are the relationships between modules - how do they interact with each other. CAN they? etc. etc. They are NOT helpful in the slightest. The post gets flagged, and most responses are responses I already know about - cuz they've done the same searches on google i have. other say buy a book! I'm not looking to be berated, or belittled.

I'm seeking real advice on the RIGHT way to use modules in a real-world environment.

I have several .pm files stored:

bc_chef.pm

bc_dir.pm

bc_misc.pm

bc_sql.pm

date.pm

html.pm

redir.pm

search.pm

security.pm

subdesc.pm

user.pm

bc_*.pm are "base code" files, i like to call them. the intent is for these particular modules to do only what they appear to do - one does JUST sql stuff, another does just cookie stuff (that's bc_chef).

so, where's my problem? you see, most of my modules need to make sure it's handing the correct data back to the client. this means that some user.pm subroutines need access to security.pm. so i put "use pm::security;" at the top of my "user.pm" file. all's good so far, i think. building on my setup, i eventually come across things like "subroutine banned(...) is not defined". I'm like thinking how can that be. I STARE at my code and just can't figure out how "use pm::security;" in my "user.pm" module can say that "banned($$)" is not defined, when it's right here in the security.pm file! makes NO SENSE! So, I get clever, you see, and I remove "use pm::security;" clause from "user.pm" and update all the references to subs in security by adding "pm::security::" to those calls. SAME error!

I clearly am missing something very fundamental to modules, but I can't, for the life of me, figure out why this is going on.

I can post some of the code (i'd have to redact a few things in many subs), but i'm willing to post code in order to gain insight into the intricacies of modules.

unless i have the concept down without knowing it, i'm feeling so lost, guys. pls don't be like stackexchange guys and flag this as "too broad" and pls don't tell me to get a dang book. none of that stuff is at all helpful.

i have scoured every site and document i can find on google, and here, and there and everywhere. most just talk about a single module. never do they say whether other modules can interact with each other, or what the relationships are.

i do understand, however, perl modules are collections of subs - related, and/or unrelated to each other. like subs, though - can a module include another module. the simple answer is yes. but, i don't understand how that relationship works.

Bottom line - i'm lost on modules and could really use some input on the finer details of modules.

thank you very kindly

Jarett

edit: (wow! what happened to my "paragragphs"? why did this thing take away my line spacing? it looks awful, drat)

edit: there, i fixed the paragraph bit, after i noticed i have to add that silly p tag


In reply to Perl Modules by jamroll

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2021-06-13 12:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (55 votes). Check out past polls.

    Notices?