473,394 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Program design in perl?

Hi,

I have a good knowledge of Perl ( 2 and half years ) and despite
working with the language that long, I have yet to build a substantial
program ( during this time I was merely testing out various aspects of
the language ). I have tried many times to build a program like a web
blog or a bulletin board but it seems that my attempts fail as soon as
I fire up the text editor! I just cannot determine what is the optimal
design to use when coding a web application.

So, I would love to read about how you guys organise your Perl code.

Thanks,
Jul 19 '05 #1
3 5486
Mohammd M. Hussain wrote:
Hi,

I have a good knowledge of Perl ( 2 and half years ) and despite
working with the language that long, I have yet to build a substantial
program ( during this time I was merely testing out various aspects of
the language ). I have tried many times to build a program like a web
blog or a bulletin board but it seems that my attempts fail as soon as
I fire up the text editor! I just cannot determine what is the optimal
design to use when coding a web application.

So, I would love to read about how you guys organise your Perl code.

Thanks,


One good approach, not just for perl, is to start by laying out the data
your project will need to deal with. A project can live or die on good
or bad data organization. List the operations needed on that data, as
these will influence the prefered representation of the data, and may
indicate additional data fields needed. For persistant data (blog,
bulitin board), consider interfacing a database (module DBI). Or if you
prefer a flat file, start coding with routines to read/write records.

Jul 19 '05 #2
On Wed, 14 Jul 2004 19:00:38 -0700, penguinista wrote:
Mohammd M. Hussain wrote:
Hi,

I have a good knowledge of Perl ( 2 and half years ) and despite
working with the language that long, I have yet to build a substantial
program ( during this time I was merely testing out various aspects of
the language ). I have tried many times to build a program like a web
blog or a bulletin board but it seems that my attempts fail as soon as
I fire up the text editor! I just cannot determine what is the optimal
design to use when coding a web application.

So, I would love to read about how you guys organise your Perl code.

Thanks,


One good approach, not just for perl, is to start by laying out the data
your project will need to deal with. A project can live or die on good
or bad data organization. List the operations needed on that data, as
these will influence the prefered representation of the data, and may
indicate additional data fields needed. For persistant data (blog,
bulitin board), consider interfacing a database (module DBI). Or if you
prefer a flat file, start coding with routines to read/write records.


Thanks for your reply,

I would like to know more details: How to handle errors ( I mean is it by
using exceptions or regular return codes ) and How the overall structure
of good modular web application should look like.

I coded an OO database interface for a blog program and
I have made it loosely-coupled so I can test it quickly and it turned out
to be fine. I would love to read suggestions about the next step(s) after
creating an abstraction layer for the DB.
Jul 19 '05 #3
>I would like to know more details: How to handle errors ( I mean is it by
using exceptions or regular return codes ) and How the overall structure
of good modular web application should look like.
Error handling during the development stage would be something like this:
(using a file read as an example)

$fname = "/path/to/file";
open (FILE, "<$fname") || die ("Unable to open $fname: $!");

If the program is gonna be released to the masses, it may be better to have
error codes and an FAQ:

$fname = "/path/to/file";
open (FILE, "<$fname") || die ("Errror 123: Consult FAQ for details !");

As for structure, personally I prefer to split a program into a series of
libraries and actions:

Example:

myscript.cgi?action=someaction
File structure:

/cgi-bin/myscript.cgi
-- Script itself
/cgi-bin/myscript_actions/
-- Directory of files with code related to specific tasks
/cgi-bin/myscript_actions/someaction/
-- Subdirectory for the specific action "someaction"
/cgi-bin/myscript_actions/someaction/code_for_this_function.pl -- Code
related to the specific action.
If you go to http://www.guestwho.com and download "GuestWho" (perl
guestbook, flatfile), you can get an idea of how I choose to structure to my
programs. This is just personal preference, there's not really a right or
wrong way to approach it.

I coded an OO database interface for a blog program and
I have made it loosely-coupled so I can test it quickly and it turned out
to be fine. I would love to read suggestions about the next step(s) after
creating an abstraction layer for the DB.


Start by thinking of one the major tasks (viewing, posting, etc) and what's
involved (such as user input, verification, etc).
Once you know what that task needs to do and what's involved with it, start
thinking about how you're going to tackle it.

After you have one task done, repeat the above with another task..
DISCLAIMER: The above is my prefered methods of operation, but I make no
claim that it is the best or only way to do it.

Regards,
Chris
Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

30
by: Christian Seberino | last post by:
How does Ruby compare to Python?? How good is DESIGN of Ruby compared to Python? Python's design is godly. I'm wondering if Ruby's is godly too. I've heard it has solid OOP design but then...
1
by: Nick Evans | last post by:
Hey all, I am currently working on a simple program (small group membership database) just to get to grips with the language (bit of a newbie here :-)) and am wondering about the best way of...
1
by: varala_kanth | last post by:
hello friends, iam new bie i run the perl program with in command mode with this following command perl <filename>.pl
1
by: Lane Beneke | last post by:
All, New to the list and a relative newbie to PostgreSQL. Please forgive stupid questions. Designing an application server for a work order processing (et al) database. I have a good handle...
3
by: sir.linying | last post by:
My php script is to call perl scipt which makes use of Spreadsheet::ParseExcel module to parse Excel file. I am able to launch php script from command line so that perl script can run and properly...
22
by: JoeC | last post by:
I am working on another game project and it is comming along. It is an improvment over a previous version I wrote. I am trying to write better programs and often wonder how to get better at...
10
by: Helpful person | last post by:
I am presently using FrontPage. I need to change to a different program because FrontPage is now obsolete. In addition, FrontPage creates awful code. Are there programs out there (Dreamweaver...
2
by: IvanIV | last post by:
Hi All, I have trouble with embedding a Perl interpreter into a C program. I would like to replace some subroutine in a Perl script without changing this script from my C program. I need...
24
by: Peter Michaux | last post by:
I have a Perl script that I want to run as a set-user-ID program. Many OSes don't allow scripts run as set-user-ID. To make this script portable, it seems I need to write a C wrapper program that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.