For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > April 2004 > Info needed...









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Info needed...
Cristi Ocolisan

2004-04-29, 10:09 am

Hi all,



Can anyone tell me where can I find a good tutorial about creating "multiple
pages" script?



Thank you.



Cristi


James Edward Gray II

2004-04-29, 4:51 pm

On Apr 29, 2004, at 6:03 AM, Cristi Ocolisan wrote:

> Hi all,
>
> Can anyone tell me where can I find a good tutorial about creating
> "multiple
> pages" script?


I can't help because I don't understand the question. What's a
"multiple pages" script? What does it do?

Are we talking about web pages? If so, how does this relate to Perl?

James

James Edward Gray II

2004-04-29, 4:51 pm

On Apr 29, 2004, at 8:51 AM, Cristi Ocolisan wrote:

> Hi,
>
> I want to write a single CGI script that can return several different
> pages
> to the browser. For instance, I want a single CGI script for
> administering a
> database of products. The script will be called to display the form to
> add a
> product, to process the add-product form, to display a list of
> products to
> delete, to process the delete-product form, to display a list of
> product to
> edit, to display a form of the product's attributes for the user to
> change,
> and to process the edit-product form.
>
> I do not know yet to write such a script and want to learn. Can you
> point me
> to some good tutorials?


I'm a book person myself and any good book on CGI should at least get
you going. You could always tried the CGI module's documentation as
well:

perldoc CGI

For the database side of things, you'll need the DBI. Grab it from the
CPAN.

James

Cristi Ocolisan

2004-04-29, 4:51 pm

Thanks,

I'll give it a try.

About DBI, I already have it. I did some Perl programming, but I'm still a
beginner. I still have some problems understanding how a "multiplescreen"
script can be made.

I'll start reading the perldoc CGI.


Regards,
Cristi

-----Original Message-----
From: James Edward Gray II [mailto:james@grayproductions.net]
Sent: 29 aprilie 2004 17:07
To: Cristi Ocolisan
Cc: Perl Beginners
Subject: Re: Info needed...

On Apr 29, 2004, at 8:51 AM, Cristi Ocolisan wrote:

> Hi,
>
> I want to write a single CGI script that can return several different
> pages
> to the browser. For instance, I want a single CGI script for
> administering a
> database of products. The script will be called to display the form to
> add a
> product, to process the add-product form, to display a list of
> products to
> delete, to process the delete-product form, to display a list of
> product to
> edit, to display a form of the product's attributes for the user to
> change,
> and to process the edit-product form.
>
> I do not know yet to write such a script and want to learn. Can you
> point me
> to some good tutorials?


I'm a book person myself and any good book on CGI should at least get
you going. You could always tried the CGI module's documentation as
well:

perldoc CGI

For the database side of things, you'll need the DBI. Grab it from the
CPAN.

James



James Edward Gray II

2004-04-29, 4:51 pm

On Apr 29, 2004, at 9:21 AM, Cristi Ocolisan wrote:

> Thanks,
>
> I'll give it a try.
>
> About DBI, I already have it. I did some Perl programming, but I'm
> still a
> beginner. I still have some problems understanding how a
> "multiplescreen"
> script can be made.


There's no one right answer, but I've seen it done more that once with
HTML's hidden form fields. You add a hidden field to the calling page
that sets the mode for the script.

Inside the script, check this parameter and call the right subroutine
to handle the requested mode.

James

James Edward Gray II

2004-04-29, 4:51 pm

On Apr 29, 2004, at 9:36 AM, Cristi Ocolisan wrote:

> I already used hidden fields, but because I couldn't figure out how to
> write
> a single script, I wrote dozens of different small scripts and sent
> that
> hidden field from one script to another.
>
> I'm tired of that. I want to write a single script that handles several
> pages...


my $mode = $query->param('mode');

if ($mode eq 'add') { add_product(); }
elsif ($mode eq 'edit') { edit_product(); }

# ... etc.

James

Wiggins D Anconia

2004-04-30, 1:18 am

> On Apr 29, 2004, at 9:36 AM, Cristi Ocolisan wrote:
>
>
> my $mode = $query->param('mode');
>
> if ($mode eq 'add') { add_product(); }
> elsif ($mode eq 'edit') { edit_product(); }
>


You may want to check out the CGI::Application module from CPAN.
Personally I haven't used it, but it seems useful for building such scripts,

http://search.cpan.org/~markstos/CG.../Application.pm

http://danconia.org
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com