Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Sub-initiate needs help getting started

by Lori713 (Pilgrim)
on Aug 27, 2003 at 13:40 UTC ( [id://287036]=note: print w/replies, xml ) Need Help??


in reply to Sub-initiate needs help getting started

Based on the advice above, here are some updates:

(1) I've loaded Eclipse and the Perl editor plug-in, and I've gotten it to work. It's given me a lovely list of modules and subroutines.

(2) We are on Sybase 12, Apache for the Unix box web server (I think - see (6) below), the reports are generated on the internet, and the reports present financial info (i.e., balance sheet, income statement).

(3) I've ordered some books that should be here this week (Debugging Pearl, the cheetah book) using my own funds. I work for the State, and we have NO money right now (they've actually starting laying off folks recently).

(4) The DBI module is not currently being used but I think there's a connection established using the Sybase::CTLib module.

(5) I am not the IT/DBA; I'm a reporting specialist who develops financial reports for our campus community.

(6) If I understood correctly, I can set up my desktop to run scripts. I currently FTP the edited text file to the Unix server, and then open a browser and type in my URL. This is not a difficult process, but it can be annoying at times. Confession: I'm not sure how all this stuff works together (i.e., the web server versus the Unix server versus the database server (BUT I will look this up on my own later today). I also plan to download Apache to my PC once I confirm that our Unix box uses that for its web server.

(7) There is minimal javascript being used, and it's pretty straightforward and understandable. I still have concerns about security (about which I know NOTHING at this point), but I'll talk to our DBAs about security issues later this week to make sure I'm covered.

(8) I have learned (painfully through experience) how vital version control is, so... 'nuff said on that.

Questions:

(a) What is the difference among the following: module, function, subroutine, script? I'd like to make sure I'm using the right terms (and understanding some of the advice given). CombatSquirrel mentioned creating some modules to help organize things. Is it best practice to have multiple "files", or have this similar-report generator all in one file? I'd appreciate advice on this. The main menu will have 7 reports, with a spot for input and a drop-down to select an accounting period. The reports will pull similar data and have a similar look, but there are differences among them.

(b) Is there any way to pull a list of variables used within a file/script/program? The Eclipse editor does a nice job of finding the subroutines and modules, but I haven't found a way to pull variables (I'd like to understand where these variables are initialized, how used, etc.).

Whew! Enough for now. I'm going to have to pitch a tent to block the evil fluorescent lights...

Thanks for all for the input and advice! Lori

  • Comment on Re: Sub-initiate needs help getting started

Replies are listed 'Best First'.
Re: Re: Sub-initiate needs help getting started
by dragonchild (Archbishop) on Aug 27, 2003 at 14:17 UTC
    • 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.

Re: Re: Sub-initiate needs help getting started
by CombatSquirrel (Hermit) on Aug 27, 2003 at 14:36 UTC
    Okay, to question (a):
    • module: A file (*.pm) that contains one or more packages
    • package: The Perl equivalent of a C namespace; encapsulates subroutines or objects
    • script: A program, so to speak. Just that it is not executed, but interpreted by the Perl interpreter
    • subroutine: You could call it a procedure or a function. It is declared with sub blabla { ... and does the stuff you tell it to do
    • function: Does not really exist in Perl, but would be (if you think Pascal), a sub that returns a value. Just understand it as sub

    To (b): I think there is a way, but I could not get it working :/. Hope the others have ideas...
    Hope this helped anyways.
    CombatSquirrel.
    Entropy is the tendency of everything going to hell.

Log In?
Username:
Password:

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

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

    No recent polls found