[25227] in Perl-Users-Digest
Perl-Users Digest, Issue: 7472 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Dec 2 00:05:35 2004
Date: Wed, 1 Dec 2004 21:05:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 1 Dec 2004 Volume: 10 Number: 7472
Today's topics:
Re: <FORM> Submit question with perl cgi scripts dogdog@noemail.com
Re: <FORM> Submit question with perl cgi scripts dogdog@noemail.com
Re: <FORM> Submit question with perl cgi scripts <jgibson@mail.arc.nasa.gov>
Re: <FORM> Submit question with perl cgi scripts <noreply@gunnar.cc>
Re: <FORM> Submit question with perl cgi scripts <1usa@llenroc.ude.invalid>
Re: <FORM> Submit question with perl cgi scripts <spamtrap@dot-app.org>
Re: <FORM> Submit question with perl cgi scripts dogdog@noemail.com
Re: <FORM> Submit question with perl cgi scripts dogdog@noemail.com
Re: <FORM> Submit question with perl cgi scripts dogdog@noemail.com
Re: <FORM> Submit question with perl cgi scripts <tadmc@augustmail.com>
Re: <FORM> Submit question with perl cgi scripts <spamtrap@dot-app.org>
Re: <FORM> Submit question with perl cgi scripts <jurgenex@hotmail.com>
FAQ 8.47: How do I keep my own module/library directory <comdog@panix.com>
Re: how to manage phpBB, windows 2003 server and FreeBS (jiing)
Re: Perl Books <matthew.garrish@sympatico.ca>
Re: Perl Books <apeiron@coitusmentis.info>
Re: Perl Books <1usa@llenroc.ude.invalid>
Re: Perl Books (Jay Tilton)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 01 Dec 2004 23:53:51 GMT
From: dogdog@noemail.com
Subject: Re: <FORM> Submit question with perl cgi scripts
Message-Id: <pan.2004.12.01.23.53.52.116485@noemail.com>
On Wed, 01 Dec 2004 17:49:34 +0000, Sherm Pendley wrote:
> dogdog@noemail.com wrote:
>
>> 1. Have the response post back to my original webpage and
>> not create a seperate page with the information.
>
> CGI.pm is well suited for that. By default, its methods for producing
> form elements will read the values it assigns to those elements from the
> incoming request.
>
>> Any way to do this?
>
> All is revealed in the docs for CGI.pm:
>
> perldoc CGI
>
> or
>
> <http://stein.cshl.org/WWW/software/CGI/>
>
> sherm--
Sherm,
I was just reading about cgi.pm in the mouse or rat book
by o'reily (whatever its called). It seems this will work
but I'm still not 100 percent clear. From what I'm reading it
seems I will
still be generating a seperate html page and moving away from
my original index page? Is that true?
What about using embperl. Do I get any benefit by including
my scripts in the html? I guess I would still need cgi.pm to
generate the output html so it looks like the original page?
Ahh the questions, it would be so much easier if I was able to
see this in action on the web.
thanks and let me know if you have answers to even more of my
questions.
tia
dogdog
------------------------------
Date: Wed, 01 Dec 2004 23:55:10 GMT
From: dogdog@noemail.com
Subject: Re: <FORM> Submit question with perl cgi scripts
Message-Id: <pan.2004.12.01.23.55.11.597851@noemail.com>
On Wed, 01 Dec 2004 23:45:21 +0100, Gunnar Hjalmarsson wrote:
> dogdog@noemail.com wrote:
>> I have my HTML document setup to submit to a cgi script. The script
>> passes information to my server and responds back as it should.
>> However, I would like to be able to do the following:
>>
>> 1. Have the response post back to my original webpage and not create
>> a seperate page with the information. 2. If 1 is possible, I would
>> like to have the items returned to the original webpage placed into
>> the textboxes that I have setup. These boxes are used when I input
>> information to the server I have and hit submit.
>
> Have the script generate the empty HTML form when invoked without
> arguments, and have it include the items when invoked via the submit
> button.
Gunnar,
Sorry to sound dense on this but I'm not very up to speed as
it is. I dont understand what your saying by empty HTML. Could
you elaborate.
tks
dogdog
------------------------------
Date: Wed, 01 Dec 2004 16:16:35 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: <FORM> Submit question with perl cgi scripts
Message-Id: <011220041616357991%jgibson@mail.arc.nasa.gov>
In article <pan.2004.12.01.23.55.11.597851@noemail.com>,
<dogdog@noemail.com> wrote:
> On Wed, 01 Dec 2004 23:45:21 +0100, Gunnar Hjalmarsson wrote:
>
> > dogdog@noemail.com wrote:
> >> I have my HTML document setup to submit to a cgi script. The script
> >> passes information to my server and responds back as it should.
> >> However, I would like to be able to do the following:
> >>
> >> 1. Have the response post back to my original webpage and not create
> >> a seperate page with the information. 2. If 1 is possible, I would
> >> like to have the items returned to the original webpage placed into
> >> the textboxes that I have setup. These boxes are used when I input
> >> information to the server I have and hit submit.
> >
> > Have the script generate the empty HTML form when invoked without
> > arguments, and have it include the items when invoked via the submit
> > button.
> Gunnar,
> Sorry to sound dense on this but I'm not very up to speed as
> it is. I dont understand what your saying by empty HTML. Could
> you elaborate.
You don't seem to have understood Gunnar's and Sherm's answers, so
there seems to be a conceptual disconnect. I will try to fill in some
of the blanks, although I will simplify somewhat.
You cannot in general add information to a web page that is already
displayed in your browser. (The exceptions are if you have a Java
applet, Javascript, or other browser-based method dynamically changing
the appearance of the web page.) It sounds like you have a static home
page (index.html) that contains a form, which you would like to submit
to a server. It is not clear if this server is the web server or
another, secondary server. You then want to get a response from this
server that the browser uses to modify the form elements or other
elements on the page.
What you can do is have your cgi program return a page that looks
exactly like your static home page with the form response information
included therein. Then it will appear as if your page has been updated
using your server response.
If that is what you want, you can take it one step further and arrange
to have your original home page generated by the same cgi program. This
is what Gunnar means by an empty HTML. The first time the page is
fetched and displayed, the forms elements are empty. If you get fancy,
you can fill them with default values or the values from a previous
fetch.
Please understand that this problem has little to do with Perl, and is
the same regardless of the language you use to implement the cgi
program. There are HTML groups to discuss this sort of thing. However,
Perl's CGI module is ideal for this sort of thing, hence Sherm's
recommendation to use it.
HTH.
------------------------------
Date: Thu, 02 Dec 2004 01:26:46 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: <FORM> Submit question with perl cgi scripts
Message-Id: <3175piF345ujuU1@individual.net>
dogdog@noemail.com wrote:
> Gunnar Hjalmarsson wrote:
>> dogdog@noemail.com wrote:
>>> I have my HTML document setup to submit to a cgi script. The
>>> script passes information to my server and responds back as it
>>> should. However, I would like to be able to do the following:
>>>
>>> 1. Have the response post back to my original webpage and not
>>> create a seperate page with the information. 2. If 1 is possible,
>>> I would like to have the items returned to the original webpage
>>> placed into the textboxes that I have setup. These boxes are used
>>> when I input information to the server I have and hit submit.
>>
>> Have the script generate the empty HTML form when invoked without
>> arguments, and have it include the items when invoked via the
>> submit button.
>
> Sorry to sound dense on this but I'm not very up to speed as it is. I
> dont understand what your saying by empty HTML. Could you elaborate.
Okay, here is a quick-and-dirty script to illustrate the idea:
#!/usr/bin/perl -T
use strict;
use warnings;
use CGI 'escapeHTML';
use File::Basename;
my $script = basename $0;
my $q = new CGI;
my %in = $q->Vars;
for ('name', 'age') {
$in{$_} ||= '';
$in{$_} = escapeHTML $in{$_};
}
print $q->header;
print <<HTML;
<html>
<body>
<form action="$script" method="post">
Name: <input type="text" name="name" value="$in{name}"><br>
Age: <input type="text" name="age" value="$in{age}"><br>
<input type="submit">
</body>
</html>
HTML
__END__
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 2 Dec 2004 01:24:52 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: <FORM> Submit question with perl cgi scripts
Message-Id: <Xns95B2CFAB76A03asu1cornelledu@132.236.56.8>
dogdog@noemail.com wrote in
news:pan.2004.12.01.23.53.52.116485@noemail.com:
> Ahh the questions, it would be so much easier if I was able to
> see this in action on the web.
There is no point in trying to do CGI development without a proper test
bed. Install Apache or another comparable web server on your development
system along with Perl and try out the examples.
And please try to keep your posts on topic. Have you read the posting
guidelines for comp.lang.perl.misc?
--
A. Sinan Unur
1usa@llenroc.ude.invalid
(remove '.invalid' and reverse each component for email address)
------------------------------
Date: Wed, 01 Dec 2004 20:40:56 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: <FORM> Submit question with perl cgi scripts
Message-Id: <-uidnZleTrk17zPcRVn-1Q@adelphia.com>
dogdog@noemail.com wrote:
> I was just reading about cgi.pm in the mouse or rat book
> by o'reily (whatever its called).
They call it a mouse. I like your rat idea better. :-)
> still be generating a seperate html page and moving away from
> my original index page? Is that true?
Yeah - there's really no way around that with CGI. You can't modify the
page in-place, all you can do is send a new page.
What you *can* do though, is send a page that's virtually identical to
the one with the form.
> Ahh the questions, it would be so much easier if I was able to
> see this in action on the web.
Here's a simple example:
#!/usr/bin/perl -T
use strict;
use warnings;
use CGI;
my $q = new CGI;
print $q->header;
my $formtag = $q->start_form;
my $nametag = $q->textfield('name');
print <<HTML;
<html>
<body>
$formtag
What's your name? $nametag<br>
<input type="submit">
</body>
</html>
HTML
When you use the textfield() method above, it looks for an input named
'name' in the query. If it finds one, it uses it to generate a value=""
attribute for the <input ...> element.
Similarly, the start_form() method produces a <form ...> element with an
action="" method that refers back to this script.
That's the basic idea - the CGI.pm methods that produce form elements
take the values assigned to those elements from the form input. This
makes it easy to build self-referential forms like you're describing.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: Thu, 02 Dec 2004 02:08:48 GMT
From: dogdog@noemail.com
Subject: Re: <FORM> Submit question with perl cgi scripts
Message-Id: <pan.2004.12.02.02.08.46.342115@noemail.com>
On Wed, 01 Dec 2004 20:40:56 +0000, Sherm Pendley wrote:
> dogdog@noemail.com wrote:
>
>> I was just reading about cgi.pm in the mouse or rat book
>> by o'reily (whatever its called).
>
> They call it a mouse. I like your rat idea better. :-)
>
>> still be generating a seperate html page and moving away from
>> my original index page? Is that true?
>
> Yeah - there's really no way around that with CGI. You can't modify the
> page in-place, all you can do is send a new page.
>
> What you *can* do though, is send a page that's virtually identical to
> the one with the form.
>
>> Ahh the questions, it would be so much easier if I was able to
>> see this in action on the web.
>
> Here's a simple example:
>
> #!/usr/bin/perl -T
> use strict;
> use warnings;
> use CGI;
>
> my $q = new CGI;
>
> print $q->header;
>
> my $formtag = $q->start_form;
> my $nametag = $q->textfield('name');
>
> print <<HTML;
> <html>
> <body>
> $formtag
> What's your name? $nametag<br>
> <input type="submit">
> </body>
> </html>
> HTML
>
> When you use the textfield() method above, it looks for an input named
> 'name' in the query. If it finds one, it uses it to generate a value=""
> attribute for the <input ...> element.
>
> Similarly, the start_form() method produces a <form ...> element with an
> action="" method that refers back to this script.
>
> That's the basic idea - the CGI.pm methods that produce form elements
> take the values assigned to those elements from the form input. This
> makes it easy to build self-referential forms like you're describing.
>
> sherm--
I thought that sending a somewhat identical page was what you were
eluding to. I'll read over more in the book and use your
example. Thanks alot for that its a great help.
dogdog
------------------------------
Date: Thu, 02 Dec 2004 02:11:32 GMT
From: dogdog@noemail.com
Subject: Re: <FORM> Submit question with perl cgi scripts
Message-Id: <pan.2004.12.02.02.11.31.169269@noemail.com>
On Wed, 01 Dec 2004 16:16:35 +0000, Jim Gibson wrote:
> In article <pan.2004.12.01.23.55.11.597851@noemail.com>,
> <dogdog@noemail.com> wrote:
>
>> On Wed, 01 Dec 2004 23:45:21 +0100, Gunnar Hjalmarsson wrote:
>>
>> > dogdog@noemail.com wrote:
>> >> I have my HTML document setup to submit to a cgi script. The script
>> >> passes information to my server and responds back as it should.
>> >> However, I would like to be able to do the following:
>> >>
>> >> 1. Have the response post back to my original webpage and not create
>> >> a seperate page with the information. 2. If 1 is possible, I would
>> >> like to have the items returned to the original webpage placed into
>> >> the textboxes that I have setup. These boxes are used when I input
>> >> information to the server I have and hit submit.
>> >
>> > Have the script generate the empty HTML form when invoked without
>> > arguments, and have it include the items when invoked via the submit
>> > button.
>> Gunnar,
>> Sorry to sound dense on this but I'm not very up to speed as
>> it is. I dont understand what your saying by empty HTML. Could
>> you elaborate.
>
> You don't seem to have understood Gunnar's and Sherm's answers, so
> there seems to be a conceptual disconnect. I will try to fill in some
> of the blanks, although I will simplify somewhat.
>
> You cannot in general add information to a web page that is already
> displayed in your browser. (The exceptions are if you have a Java
> applet, Javascript, or other browser-based method dynamically changing
> the appearance of the web page.) It sounds like you have a static home
> page (index.html) that contains a form, which you would like to submit
> to a server. It is not clear if this server is the web server or
> another, secondary server. You then want to get a response from this
> server that the browser uses to modify the form elements or other
> elements on the page.
>
> What you can do is have your cgi program return a page that looks
> exactly like your static home page with the form response information
> included therein. Then it will appear as if your page has been updated
> using your server response.
>
> If that is what you want, you can take it one step further and arrange
> to have your original home page generated by the same cgi program. This
> is what Gunnar means by an empty HTML. The first time the page is
> fetched and displayed, the forms elements are empty. If you get fancy,
> you can fill them with default values or the values from a previous
> fetch.
>
> Please understand that this problem has little to do with Perl, and is
> the same regardless of the language you use to implement the cgi
> program. There are HTML groups to discuss this sort of thing. However,
> Perl's CGI module is ideal for this sort of thing, hence Sherm's
> recommendation to use it.
>
> HTH.
Jim,
Thanks for your clarification on this. I went to the perl group
first because I was hoping that there was something in perl
that could be done outside of the html range of things
(i.e. fancy scripting tricks that are similiar to javascript
type page in place actions).
Thanks again for your clarification. Gunnar has also
submitted some samples in reference to what he was speaking of
earlier. Which I'm sure will be quite beneficial.
dogdog
------------------------------
Date: Thu, 02 Dec 2004 02:12:54 GMT
From: dogdog@noemail.com
Subject: Re: <FORM> Submit question with perl cgi scripts
Message-Id: <pan.2004.12.02.02.12.53.362613@noemail.com>
On Thu, 02 Dec 2004 01:26:46 +0100, Gunnar Hjalmarsson wrote:
> dogdog@noemail.com wrote:
>> Gunnar Hjalmarsson wrote:
>>> dogdog@noemail.com wrote:
>>>> I have my HTML document setup to submit to a cgi script. The
>>>> script passes information to my server and responds back as it
>>>> should. However, I would like to be able to do the following:
>>>>
>>>> 1. Have the response post back to my original webpage and not
>>>> create a seperate page with the information. 2. If 1 is possible,
>>>> I would like to have the items returned to the original webpage
>>>> placed into the textboxes that I have setup. These boxes are used
>>>> when I input information to the server I have and hit submit.
>>>
>>> Have the script generate the empty HTML form when invoked without
>>> arguments, and have it include the items when invoked via the
>>> submit button.
>>
>> Sorry to sound dense on this but I'm not very up to speed as it is. I
>> dont understand what your saying by empty HTML. Could you elaborate.
>
> Okay, here is a quick-and-dirty script to illustrate the idea:
>
> #!/usr/bin/perl -T
> use strict;
> use warnings;
> use CGI 'escapeHTML';
> use File::Basename;
>
> my $script = basename $0;
> my $q = new CGI;
> my %in = $q->Vars;
> for ('name', 'age') {
> $in{$_} ||= '';
> $in{$_} = escapeHTML $in{$_};
> }
>
> print $q->header;
> print <<HTML;
> <html>
> <body>
> <form action="$script" method="post">
> Name: <input type="text" name="name" value="$in{name}"><br>
> Age: <input type="text" name="age" value="$in{age}"><br>
> <input type="submit">
> </body>
> </html>
> HTML
>
> __END__
Gunnar,
Thanks alot for the example. Its great when a person can get
an answer like yours and Sherms with some helpful examples.
I can then use them along with what is in text and on the
web to assist in clarifying things and gain a better understanding.
thanks alot
dogdog
------------------------------
Date: Wed, 1 Dec 2004 20:41:33 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: <FORM> Submit question with perl cgi scripts
Message-Id: <slrncqt06t.8tj.tadmc@magna.augustmail.com>
dogdog@noemail.com <dogdog@noemail.com> wrote:
[ snip TOFU foolishness, learn how to properly quote followups. ]
> Thanks alot for the example. Its great when a person can get
> an answer like yours and Sherms with some helpful examples.
STOP THE TOP-POSTING already!
Sheesh man, please make some attempt to fit in here.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 01 Dec 2004 21:55:31 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: <FORM> Submit question with perl cgi scripts
Message-Id: <X8GdnRUebpq5GTPcRVn-iA@adelphia.com>
Tad McClellan wrote:
> STOP THE TOP-POSTING already!
What are you talking about? His quoting may have been a bit excessive,
but his reply was at the bottom. He didn't top-post. In fact, I can't
see that he's done any top-posting in this whole thread.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: Thu, 02 Dec 2004 04:35:46 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: <FORM> Submit question with perl cgi scripts
Message-Id: <CYwrd.10828$xk5.1425@trnddc09>
dogdog@noemail.com wrote:
> Thanks for your clarification on this. I went to the perl group
> first because I was hoping that there was something in perl
> that could be done outside of the html range of things
> (i.e. fancy scripting tricks that are similiar to javascript
> type page in place actions).
You may want to read up on the difference between client side scripting and
server side scripting. Because CGI is server- side scripting of course the
context and the capabilities are totally different from client-side
JavaScript.
Of course you could always use client-side PerlScript, then you get similar
capabilities as in JavaScript or VB Script.
Oh, and of course none of this has anything to do with the programming
language Perl, so please take the discussion to a more appropriate NG like
e.g. some with CGI or HTML in its name.
jue
------------------------------
Date: Thu, 2 Dec 2004 05:03:01 +0000 (UTC)
From: PerlFAQ Server <comdog@panix.com>
Subject: FAQ 8.47: How do I keep my own module/library directory?
Message-Id: <com7m5$47o$1@reader1.panix.com>
This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with Perl.
--------------------------------------------------------------------
8.47: How do I keep my own module/library directory?
When you build modules, use the PREFIX and LIB options when generating
Makefiles:
perl Makefile.PL PREFIX=/mydir/perl LIB=/mydir/perl/lib
then either set the PERL5LIB environment variable before you run scripts
that use the modules/libraries (see perlrun) or say
use lib '/mydir/perl/lib';
This is almost the same as
BEGIN {
unshift(@INC, '/mydir/perl/lib');
}
except that the lib module checks for machine-dependent subdirectories.
See Perl's lib for more information.
--------------------------------------------------------------------
Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short. They represent an important
part of the Usenet tradition. They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.
If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile. If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.
Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release. It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.
The perlfaq manual page contains the following copyright notice.
AUTHOR AND COPYRIGHT
Copyright (c) 1997-2002 Tom Christiansen and Nathan
Torkington, and other contributors as noted. All rights
reserved.
This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.
------------------------------
Date: 1 Dec 2004 18:36:30 -0800
From: jiing.deng@gmail.com (jiing)
Subject: Re: how to manage phpBB, windows 2003 server and FreeBSD user accounts simultaneously.
Message-Id: <b7b95676.0412011836.243444e1@posting.google.com>
Michele Dondi <bik.mido@tiscalinet.it> wrote in message news:<k3brq099fflq3m985po09voq7tdi4qu51u@4ax.com>...
> On 30 Nov 2004 23:08:08 -0800, jiing.deng@gmail.com (jiing) wrote:
>
> >Thanks Michele, it's good to get your response.
> >Let me restate my question again.
> >I want to manage the accounts of phpBB (someone said it just need to
> ^^^
> ^^^
>
> >modify the database of phpBB, I am not quite sure), accounts of
> ^^^
> ^^^
>
> Well, phpBB is a CMS written in php. So a priori it is doubtful that
> "native support" for Perl is provided. I don't even know if it is
> possible, but it may be that someone has written a Perl module to do
> what you want anyway. In that case search CPAN. Did you find anything?
>
> >Windows 2003 server, and accounts of FreeBSD.
> >I have tried to find out some CPAN modules that may be useful:
> [snip]
>
> In that case, OK: there are probably modules to do what you want.
>
> >But I am just a newbie of Perl, and not very sure what I should do,
> >what information I should find.
>
> If you are willing to listen to my humble opinion, then you should
> first become familiar at least with the very basics of Perl. Then and
> only then you can even *begin* to think of using whatever module to
> manage complex tasks, let alone potentially risky ones like those
> you're dealing with.
>
> >in fact, I do not know the account management at all, either in
> >FreeBSD or in Windows 2003 server.
>
> Ditto as above.
>
> Please note that dealing with such delicate areas is a kind of
> activity that even many Perl (or other languages FWIW) experts will
> handle with MUCH, MUCH care. So... be careful. And patient!
>
> >Can anyone give me some suggestion?
> >thanks a lot.
>
> I'm afraid I can't give you any beyond what I wrote above. Sorry!
>
>
> Michele
Michele, thanks for your sincere option.
My boss told me phpBB part can be solved by directly access the mySQL database.
/jiing/
------------------------------
Date: Wed, 1 Dec 2004 18:52:29 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: Perl Books
Message-Id: <_Osrd.21222$Ad3.1351274@news20.bellglobal.com>
"Paul Lalli" <mritty@gmail.com> wrote in message
news:uVord.3993$8v3.586@trndny08...
> "Binny V A" <binnyva@hotmail.com> wrote in message
> news:68cd8f94.0412011107.1f7cd47f@posting.google.com...
>> Hello Everyone,
>>
>> I have written a tutorial and would like to suggest a couple of good
>> Perl related books. But since I have little knowledge of perl books, I
>> have to come to you for aid. Would you recommend some good books for a
>> perl beginner.
>
>
> If you can get the spelling and grammar fixed, I might take another look
> at the remainder of the tutorial.
>
Couldn't agree more. I particularly liked this gem:
One of the most noted disadvangtages of perl is it bad redability.
Matt
------------------------------
Date: 2 Dec 2004 00:14:33 GMT
From: Christopher Nehren <apeiron@coitusmentis.info>
Subject: Re: Perl Books
Message-Id: <slrncqsnj9.1r6l.apeiron@prophecy.dyndns.org>
On 2004-12-01, Matt Garrish scribbled these
curious markings:
> One of the most noted disadvangtages of perl is it bad redability.
And some people don't even see that as a "disadvangtage". :)
--
I abhor a system designed for the "user", if that word is a coded
pejorative meaning "stupid and unsophisticated". -- Ken Thompson
Linux: "How rebellious ... in a conformist sort of way."
Unix is user friendly. However, it isn't idiot friendly.
------------------------------
Date: 2 Dec 2004 02:07:30 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Perl Books
Message-Id: <Xns95B2D6E6223F0asu1cornelledu@132.236.56.8>
Uri Guttman <uri@stemsystems.com> wrote in
news:x7oehdpziy.fsf@mail.sysarch.com:
>>>>>> "BVA" == Binny V A <binnyva@hotmail.com> writes:
>
> BVA> I have written a tutorial and would like to suggest a couple of
From http://www.geocities.com/binnyva/code/perl/:
<quotation>
I have written a good tutorial for CGI Perl.
</quotation>
I find this statement astonishing in its lack of humility given that BVA
does not even know of any good Perl books to recommend.
> and this straw breaks the camel's back.
>
> Some places where great Perl Scripts are available...
> http://www.geocities.com/binnyva/code/perl/
...
> and i took a gander at your guestbook script. it has too many bugs and
> too much bad code to even review. i will leave that to any others here
> if they want the fun and glory.
The quotation from BVA's web site provided enough motivation for me to
take a look at the guestbook script. Here are a few points:
use strict;
use warnings;
missing.
> # Get input
> my $value;
> if ($ENV{'REQUEST_METHOD'} eq "GET")
> {
> $value = $ENV{'QUERY_STRING'};
> }
> # else {
> # $value = <STDIN>;
> # }
Have you heard of CGI.pm?
> # Take time to make things happen
Non-sensical comments like this are worse than no comments at all.
> ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
> localtime(time);
First, you are not using all the values returned by localtime. So, assign
only those you need:
my ($mday, $mon, $year) = (localtime(time))[3,4,5];
> $year = $year - 100;
Second, the correct way to handle the year value returned by localtime is
shown in perldoc -f localtime.
> $mon++;
> $date = "$mday$seperator$mon$seperator 200$year";
Incidentally, the correct spelling is separator.
What does this print on 1 December 2010? Let's see:
use strict;
use warnings;
my $mday = 1;
my $mon = 12;
my $year = 110 - 100;
my $separator = '-';
print "$mday$separator$mon$separator 200$year";
__END__
C:\Home> tttt
1-12- 20010
Oh, ain't that a beauty?
use strict;
use warnings;
my $separator = '-';
my ($mday, $mon, $year) = (localtime(time))[3,4,5];
$mon += 1;
$year += 1900;
my $date = "$mday$separator$mon$separator$year";
print $date;
Not that I recommend this method formatting dates. Quick, is 1-12-2004
January 12th or December 1st?
> # Making the input English. And removing unwanted things
Again, nonsensical comments are worse than no comments at all.
> $value =~ s/%(..)/pack("c", hex($1))/ge;
> $value =~ s/name\=//gi;
> $value =~ s/email\=//gi;
> $value =~ s/loc\=//gi;
> $value =~ s/comments\=//gi;
> $value =~ s/rating\=//gi;
> $value =~ s/strength\=//gi;
> $value =~ s/\+/ /gi;
> $value =~ s/\n/<BR>/gi;
Why did you do that to the query string?
> # Catogarizing the input
Non-sensical comments are worse than no comments at all.
> @value = split(/&/, "$value");
Useless use of quotes.
> $name = $value[0];
> $email = $value[1];
> $location = $value[2];
> $comments = $value[3];
> $rating = $value[5];
> $strength = $value[6];
I see what you are doing now and I am horrified. This is very fragile.
Your technique (aside from other flaws) relies on variables appearing in
a specific order within the query string.
At this point, your best bet is to use CGI.pm.
> # Open Guest Book File
> open (FILE, "$guestfile") || print "Can't open $guestfile: $!\n";
Tears in my eyes ... So, if you fail to open the file you want read from,
you react by printing a message to STDOUT
> @LINES=<FILE>;
and then reading from the file. Sweet!
# Open Guest Book File and inputing the content on top
open (FILE, ">$guestfile") || print "Can't open $guestfile: $!\n";
So, if you fail to open the file you want to write to, you react by
printing a message on STDOUT
> for ($i = 0; $i <= $SIZE; $i++)
> {
> $_=$LINES[$i];
> if (/<!--top-->/)
> {
> print FILE "<!--top-->\n";
And then writing to an invalid file handle anyway. Double sweet!!!
Furthermore, you have no idea how to loop through invidual elements of an
array.
for (@LINES) {
# do something with each line
}
In short, you should scrap this script and go back to learning Perl.
--
A. Sinan Unur
1usa@llenroc.ude.invalid
(remove '.invalid' and reverse each component for email address)
------------------------------
Date: Thu, 02 Dec 2004 02:59:28 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Perl Books
Message-Id: <41ae79b1.163087357@news.erols.com>
binnyva@hotmail.com (Binny V A) wrote:
: I have written a tutorial
Writing is more than just typing.
Write for your audience. Your audience will be people with minimal
experience with Perl, or even minimal experience with any sort of
programming. They will value accurate information that is presented
quickly. This draft of your tutorial is excessively verbose,
inappropriately casual, and it is peppered with countless errors.
Text that is unreadable is not going to be read. Spelling, grammar, and
punctuation matter more than you might think.
Writing is not a one-person job. Run the text through the review/revise
cycle a few dozen times with a cooperative expert.
Test your sample programs. More than one of them does something different
than it should.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 7472
***************************************