Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
  • Function / Subroutine / Procedure - In Perl, these terms are interchangeable. (In other languages, like Pascal, function means something different than procedure, but don't worry about that.) This represents a grouping of statements, usually with a defined set of input and a defined set of output. You want these because they will simplify your life. (Instead of writing the same 10 lines over and over, just with different variable names, you create a function and pass the variables to it.) "sub" or "func" are common abbreviations.
  • Script - this is a Perl executable. Your pages / reports will have a script associated with them. A script has a bunch of lines of code in it, many of which are usually in a bunch of subs. It will almost always farm out some of the work to a bunch of modules. (For example, CGI is a good example.)
  • Module - a separate file that contains a bunch of functions which perform similar or related work. For example, the CGI module has over 100 different functions, all of which are related to input from and output to the Web. There are literally thousands of modules on CPAN and you are encouraged to write your own.
  • Package - while often interchangeable with Module, this word has special meaning in Perl. It describes a namespace. Usually, one has one Package in one file, but not always.

As for your design, I would reccomend the following:

  • Have your basic reporting work be in one module. This would include all the queries to the database and any basic transformations on the data that comes back that might be needed. A good rule of thumb is that if you have the same (or very similar) code in more than one place, you should put it in a module.
  • Have one script for each report. This is where you keep what is unique about each report. It could be a formatting thing, or maybe one report is a detail report vs. another which is a summary report. That is the stuff that goes into the script that is specific to a given report.
  • Have one script for each screen. So, you probably have a login screen, a choose-report screen, etc.
  • When you get to using templates, you will want to have a template for every different screen you want to present to your users. So, you'd have a template for each report and a template for each screen.

------
We are the carpenters and bricklayers of the Information Age.

The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.


In reply to Re: Re: Sub-initiate needs help getting started by dragonchild
in thread Sub-initiate needs help getting started by Lori713

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 How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2024-03-28 19:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found