Old tutorial - now corrected

Discussion in 'Perl Misc' started by Binny V A, Jan 25, 2005.

  1. Binny V A

    Binny V A Guest

    I am the author of the "Beginner's Tutorial for CGI
    Perl Language" at
    http://www.geocities.com/binnyva/code/perl/tutorial/index.html
    This is a tutorial for the perl language. Teaches how
    to develop CGI(Common Gateway Interface) perl programs
    for websites.

    It was the subject of a few posts a couple of months ago -
    http://tinyurl.com/3l2t2

    I believe that I have corrected all the problems that
    were pointed out in those posts. Anyone interested can
    take a look at it. If you notice any more errors, please
    let me know. I certainly expect to find some after
    seeing the results of my previous attempt. After all
    that is debugging - taking out old bugs and putting
    in new ones. ;-)

    PS : Sorry about the delay in repairing the tutorial.

    Thank You,
    Binny V A
    http://www.geocities.com/binnyva/code
     
    Binny V A, Jan 25, 2005
    #1
    1. Advertising

  2. (Binny V A) wrote in
    news::

    > I am the author of the "Beginner's Tutorial for CGI
    > Perl Language" at
    > http://www.geocities.com/binnyva/code/perl/tutorial/index.html

    ....

    > It was the subject of a few posts a couple of months ago -
    > http://tinyurl.com/3l2t2
    >
    > I believe that I have corrected all the problems that
    > were pointed out in those posts. Anyone interested can
    > take a look at it. If you notice any more errors, please
    > let me know.


    OK. I'll bite. You know, you could make it much easier for people to
    comment if we could just see the source code on your site rather than
    having to download a zip and extract the source etc etc.

    My comments pertain to:

    # Name Of Script : Message Board
    #
    # Version : 1.00.A

    First thing I noticed is that there is still no

    use strict;

    That is kind of obnoxious of you.

    > # Set Variables
    > $file = "message_board.html"; # The File where the message
    > board is displayed
    > $messagesfile = "messages.html"; # The file that stores all the
    > messages
    > $seperator = "-"; # Date sepeator (9'-'10..)


    First off, do away with useless right margin comments such as these.
    Second, the word is spelled 'separator'. Third, you are better off using
    a hash for this sort of thing:

    my %config = (
    board_file => 'message_board.html',
    messages_file => 'messages.html',
    date_separator => '-',
    );

    Now, the kicker:

    > # Get input
    > my $value;
    > if ($ENV{'REQUEST_METHOD'} eq "GET")
    > {
    > $value = $ENV{'QUERY_STRING'};
    > }
    > else
    > {
    > $value = <STDIN>;
    > }


    Oh, get ready for fun CGI parsing ...

    use CGI ':standard';
    $CGI::pOST_MAX = 100*1024;
    $CGI::DISABLE_UPLOADS = 1;

    > # Take time to make things happen
    > ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime
    > (time);
    > $year = $year - 100;
    > $mon++;
    > $date = "$mday$seperator$mon$seperator200$year";


    It looks like you still haven't read the responses to your original
    postings. Neither have you bothered to look at

    perldoc -f localtime

    What if the year is 2014? Then, $date above will be set to
    "26-1-20014". Do you think that is correct? If so, you are even more
    dimwitted than I give you credit for.

    Encapsulate this in a sub:

    sub formatted_date {
    my $separator = shift;
    my ($mday, $month, $year) = (localtime time)[3, 4, 5];
    sprintf('%2.2d%s%2.2d%s%4.4d',
    $mday,
    $separator,
    ++$month,
    $separator,
    1900 + $year
    );
    }

    I cannot remember the name of the module on CPAN that deals with
    formatting dates according to the RFC whose number I cannot remember
    (here is an idea, why don't you search CPAN yourself and find the
    appropriate date formatting module?)

    > # Making the input English. And removing unwanted things


    WTF does this mean? What if I posted something in Turkish on this site?
    Have you written a translator for Turkish -> English that Google does
    not know about?

    > $value =~ s/%(..)/pack("c", hex($1))/ge;
    > $value =~ s/comments\=//gi;
    > $value =~ s/\+/ /gi;
    > $value =~ s/\n/<BR>/gi;
    > # Catogarizing the input


    Speaking of English ...

    > @value = split(/&/, "$value" );
    > $comments = $value[0];


    Please do everyone a favor and use CGI.pm.

    > # Open Guest Book File
    > open (FILE, "$messagesfile") ||


    Useless use of quotes. See

    perldoc -q always

    > print "Can't open $messagesfile: $!\n";
    > @LINES=<FILE>;
    > close(FILE);
    > $SIZE=@LINES;


    We have been through this once before. You try to open a file. If there
    is an error, you print something and continue on to read lines from the
    file that you failed to open.

    Finally, I urge everyone to stay away from scripts that allow people to
    write arbitrary amounts of data to your server's hard drive. Please.

    Sinan.
     
    A. Sinan Unur, Jan 25, 2005
    #2
    1. Advertising

  3. Binny V A

    Guest

    Most of the programs there are very old relics - about
    two to three years old - I am too lazy to update them.
    I should do that - I know. Maybe sometime this year...

    Anyway the subject is the tutorial - not my old scripts.
    Thank You,
    Binny V A
    http://www.geocities.com/binnyva/code
     
    , Jan 26, 2005
    #3
  4. Binny V A

    Tore Aursand Guest

    wrote:
    > Most of the programs there are very old relics - about
    > two to three years old - I am too lazy to update them.
    > I should do that - I know. Maybe sometime this year...
    >
    > Anyway the subject is the tutorial - not my old scripts.


    Aren't the scripts _a part of_ the tutorial?


    --
    Tore Aursand <>
    "To cease smoking is the easiset thing I ever did. I ought to know,
    I've done it a thousand times." (Mark Twain)
     
    Tore Aursand, Jan 26, 2005
    #4
  5. "Bernard El-Hagin" <> wrote in
    news:Xns95EA5BD28E103elhber1lidotechnet@62.89.127.66:

    > "A. Sinan Unur" <> wrote:
    >
    >> What if the year is 2014? Then, $date above will be set to
    >> "26-1-20014". Do you think that is correct? If so, you are even
    >> more dimwitted than I give you credit for.

    >
    > The line between being critical and being needlessly abusive is not
    > fine by any means. You have managed to cross it anyway.


    I agree that the last sentence of that paragraph was completely
    unnecessary and indeed my point would have been better made had I had
    the sense not to post that. I apologize.

    On the other hand, please take a look at:

    <http://groups-
    beta.google.com/group/comp.lang.perl.misc/msg/ec9bf41c19ec1b40>
    (<http://tinyurl.com/4gyfy>)

    and compare it to my comments this time.

    The OP claimed that he had read the comments and made changes to take
    those comments into account. Upon reading his code again, I did not
    think he had actually done that at all.

    Elsethread, the OP has claimed that the code I commented on was not part
    of the tutorial. I am not able to figure out what is and what is not a
    part of the tutorial. I simply followed the link he posted. There was
    some stuff about men and cowards and LOC etc and some links listed on
    the left. So, I followed one of those links, specifically, the one that
    said 'Perl'.

    Going back, I now see a link titled "Next" on the page. I did not see
    that originally.

    To bring up the usefullness quotient of this thread a little, I am going
    to recommend "Picking up Perl" to anyone who is looking for an
    introductory Perl tutorial:

    http://www.ebb.org/PickingUpPerl/

    Actually visiting:

    http://learn.perl.org/

    and seeing what is available to new users would also not be a bad idea.

    Sinan.
     
    A. Sinan Unur, Jan 26, 2005
    #5
  6. <> wrote:
    >
    > Most of the programs there are very old relics - about
    > two to three years old - I am too lazy to update them.



    It would take about 20 seconds to remove the links to them.


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Jan 26, 2005
    #6
  7. Binny V A

    Anno Siegel Guest

    Bernard El-Hagin <> wrote in comp.lang.perl.misc:
    > "A. Sinan Unur" <> wrote:
    >
    > > What if the year is 2014? Then, $date above will be set to
    > > "26-1-20014". Do you think that is correct? If so, you are even
    > > more dimwitted than I give you credit for.

    >
    > The line between being critical and being needlessly abusive is not
    > fine by any means. You have managed to cross it anyway. You do so on a
    > regular basis. It was uncalled for in this case and is uncalled for
    > almost every time you stoop to it.


    Then again, a "tutorial" that introduces its very own Y2010 bug, in a
    revised edition, no less, must be considered beyond redemption. Strong
    discouragement is indicated.

    Anno
     
    Anno Siegel, Jan 26, 2005
    #7
  8. Binny V A

    Anno Siegel Guest

    <> wrote in comp.lang.perl.misc:
    >
    > Most of the programs there are very old relics - about
    > two to three years old - I am too lazy to update them.
    > I should do that - I know. Maybe sometime this year...


    Too *lazy*? In publishing your Perl pages, tutorial, scripts, whatever,
    you have taken on an obligation to maintain them according to your best
    knowledge.

    You are doing the Perl community a disservice. Take them down.

    Anno
     
    Anno Siegel, Jan 26, 2005
    #8
  9. Binny V A

    Guest

    The scripts are not the part of the tutorial - at the end of the
    tutorial I gave some sample CGI scripts by giving links to my
    collection at http://www.geocities.com/binnyva/code/perl/ and to CGI's
    other resource sites like http://cgi.resourceindex.com/ and
    http://www.scriptarchive.com/.
    A link in a tutorial does NOT makes the target file a part of the
    tutorial - I almost hope it would - then http://cgi.resourceindex.com/
    would be a part of my tutorial.
    Can we concentrate on my tutorial, please?
     
    , Jan 26, 2005
    #9
  10. Binny V A

    Guest

    I admit that I should correct those scirpts - I will.
    But please not that those are functional scirpt -
    just not perfect. They have some bugs. The most
    noted problem was that I did not use CGI.pm
    module. One should remember that not everyone
    has the CGI.pm module. They should be having it -
    but its not a perlfect(sic) world.

    But I promise that I will correct the bugs as soon
    as possible.

    Thank you,
    Binny V A
    http://www.geocities.com/binnyva/code
     
    , Jan 26, 2005
    #10
  11. Binny V A

    Anno Siegel Guest

    <> wrote in comp.lang.perl.misc:
    > I admit that I should correct those scirpts - I will.
    > But please not that those are functional scirpt -

    ^^^
    That must be a Freudian slip. They're probably as functional as M*tt's
    Script Archive.

    If the bit of date manipulation code that was shown here is any indication,
    you are *way* too inexperienced in Perl, and programming in general, to be
    publishing code. Stop it.

    Anno
     
    Anno Siegel, Jan 26, 2005
    #11
  12. On Wed, 26 Jan 2005 wrote:

    > The scripts are not the part of the tutorial


    Look, give it a rest already. You're quite dangerous to be let loose
    on beginners, but you don't seem to want to recognise the fact.

    If you /really/ took the advice you're getting here, you'd take that
    stuff off the web for the time being. But you seem to be deaf to that
    part of the advice (and to too much of the rest too). I suppose all
    we can do is offer a "c.l.p.m health warning" and hope that it'll
    reach at least some of your intended audience.

    Don't take this wrong - we all have to start somewhere, and there's no
    shame in being a beginner - but that doesn't mean rushing right out
    and publishing a premature tutorial.
     
    Alan J. Flavell, Jan 26, 2005
    #12
  13. <> wrote:


    > Can we concentrate on my tutorial, please?



    That would be a waste of effort.

    You are not qualified to do what you are doing, please
    stop doing it.


    No code is *better* than bad code!


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Jan 27, 2005
    #13
  14. wrote in news:1106766154.428651.174550
    @f14g2000cwb.googlegroups.com:

    > The scripts are not the part of the tutorial.


    ....

    > Can we concentrate on my tutorial, please?


    I am assuming
    http://www.geocities.com/binnyva/code/perl/tutorial/cgi_perl.html is
    part of your tutorial. There, you discuss at length your guestbook
    script as an example of how to do CGI programming in Perl.

    All code below are from the URL given above.

    > Now lets get the input...
    >
    > my $query_string = "";
    > #Get the input
    > if ($ENV{REQUEST_METHOD} eq 'POST') {
    > read(STDIN, $query_string, $ENV{CONTENT_LENGTH});


    read can fail, you know.

    > } else {
    > $query_string = $ENV{QUERY_STRING};
    > }
    > ##### We will remove this
    > print "Content-Type: text/html\n\n";
    > print "Query String is \n<br> $query_string";
    > ##### We will remove this


    Why do you claim to be returning HTML when you are not?



    > The data will be in this format -
    > <Input name>=<Inputted Data>&<Next Input name>=<Next Inputted Data>
    > and so on


    So, you are not going to handle:

    http://www.example.com/cgi-bin/test.pl?field1=One;field2=Two

    > Now add the following lines to the guestbook.pl file...
    >
    > # Split the name-value pairs
    > @pairs = split(/&/, $query_string);
    >
    > foreach $pair (@pairs) {
    > ($name, $value) = split(/=/, $pair);
    >
    > # Making the input English. And removing unwanted things
    > $value =~ tr/+/ /;
    > $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    >
    > $FORM{$name} = $value;
    > }


    You just copied and pasted this block of code without understanding what
    it does. You are recommending to beginners that they do the same. There
    is no point to doing this in a beginners' tutorial. You should just use
    CGI.pm. Then, if anyone wants to hand-parse CGI, they can look at the
    source code for CGI.pm to learn how to do it properly. That would be
    useful for you as well.

    Oh, and don't claim that some people may not have CGI.pm. Any Perl
    installation that does not have CGI.pm is broken.

    But, of course, the real kicker is:

    > For a better guest book program that I have created, go
    > to http://www.geocities.com/binnyva/code/perl/cgi/guestbook.html.


    I would say this kind of reference does indeed make the scripts part of
    your tutorial.

    Anyway, I think I have had my fill of this.

    Sinan
     
    A. Sinan Unur, Jan 27, 2005
    #14
  15. Binny V A

    Eric Bohlman Guest

    wrote in news:1106766522.966545.9750
    @z14g2000cwz.googlegroups.com:

    > I admit that I should correct those scirpts - I will.


    > But please not that those are functional scirpt -
    > just not perfect. They have some bugs. The most


    Most people with any experience in programming wouldn't consider
    "functional" to be a useful way of saying "works only when conditions are
    just right." A "functional" program works properly regardless of the
    phase of the moon or the particular variety of goat you sacrifice.

    The big issue here is your intended audience. By definition, a beginner
    in any subject is someone who doesn't know enough about that subject to
    be able to tell bad examples apart from good examples. Therefore, anyone
    who writes a tutorial really, really, needs to make sure that all their
    examples are as close to perfect as is humanly possible. If you present
    beginners with half-assed examples, they'll internalize them and that
    will put a big stumbling block in front of their future learning. It's
    *much* harder for someone to unlearn The Wrong Way To Do It and
    subsequently learn the Right Way To Do It than it is to learn the Right
    Way from scratch.

    You should make every possible effort *not* to expose beginners to
    example code that contains bugs except as part of efforts to teach them
    how to recognize bugs.

    > noted problem was that I did not use CGI.pm
    > module. One should remember that not everyone
    > has the CGI.pm module. They should be having it -
    > but its not a perlfect(sic) world.


    CGI.pm has been part of the default Perl distribution for at least 7
    years. Therefore, if someone doesn't have it, either they haven't
    updated their Perl distribution since the mid-90s or they didn't install
    the distribution properly. Under such circumstances, learning any aspect
    of Perl programming is going to be unnecessarily difficult.
     
    Eric Bohlman, Jan 27, 2005
    #15
  16. Binny V A

    brian d foy Guest

    In article <Xns95EB1A0C76EA9ebohlmanomsdevcom@130.133.1.4>, Eric
    Bohlman <> wrote:

    > wrote in news:1106766522.966545.9750
    > @z14g2000cwz.googlegroups.com:


    > > I admit that I should correct those scirpts - I will.


    > > But please not that those are functional scirpt -
    > > just not perfect. They have some bugs. The most


    > Most people with any experience in programming wouldn't consider
    > "functional" to be a useful way of saying "works only when conditions are
    > just right.


    Indeed, "functional" means something different than
    "functioning" or "working". :)

    --
    brian d foy,
    Subscribe to The Perl Review: http://www.theperlreview.com
     
    brian d foy, Jan 27, 2005
    #16
  17. On Thu, 27 Jan 2005, brian d foy wrote:

    > Indeed, "functional" means something different than
    > "functioning" or "working". :)


    And "Functional Programming" has a rather specialised meaning.

    Hmmm: http://www.dcs.gla.ac.uk/fp/pictures/lambda-and-chip.gif

    Not my cup of tea, though.
     
    Alan J. Flavell, Jan 27, 2005
    #17
  18. Binny V A

    Guest

    Not everybody said that I have to junk my tutorial.
    Two or three persons said that - the majority said that I
    have to improve the tutorial. Anyway even if everyday
    would have asked me to trash the tutorial, I would not
    have done so. Come on guys, we are programmers - if we
    see a lot of errors when we first run a new program, do
    we scrape the project or do we correct it? Thats what I
    am trying to do.

    Binny.
     
    , Jan 27, 2005
    #18
  19. Binny V A

    Paul Lalli Guest

    <> wrote in message
    news:...
    > Come on guys, we are programmers - if we
    > see a lot of errors when we first run a new program, do
    > we scrape the project or do we correct it? Thats what I
    > am trying to do.


    But in the *meantime*, you are displaying faulty code allegedly
    intentioned to help new programmers. Professional programmers do NOT
    release code they know to be buggy *before* repairing it. It is not
    good enough to say that you'll eventually fix it, all the while allowing
    the possibility of some unsuspecting newbie finding and attempting to
    learn from it. That is, I believe, what most people are complaining
    about.

    Paul Lalli
     
    Paul Lalli, Jan 27, 2005
    #19
  20. Binny V A

    Anno Siegel Guest

    <> wrote in comp.lang.perl.misc:
    > Not everybody said that I have to junk my tutorial.
    > Two or three persons said that - the majority said that I
    > have to improve the tutorial. Anyway even if everyday
    > would have asked me to trash the tutorial, I would not
    > have done so.


    Then why did you ask our opinion?

    > Come on guys, we are programmers - if we
    > see a lot of errors when we first run a new program, do
    > we scrape the project or do we correct it? Thats what I
    > am trying to do.


    "We" don't publish every brain fart on the web. That's what you're doing,
    and it's wrong.

    Anno
     
    Anno Siegel, Jan 27, 2005
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?iso-8859-1?Q?Fran=E7ois?= Pinard

    Re: NEW MAINTAINER for Pymacs [corrected]

    =?iso-8859-1?Q?Fran=E7ois?= Pinard, Sep 24, 2004, in forum: Python
    Replies:
    2
    Views:
    339
    =?iso-8859-1?Q?Fran=E7ois?= Pinard
    Sep 24, 2004
  2. Markus Franz
    Replies:
    2
    Views:
    368
    Denis S. Otkidach
    Dec 28, 2004
  3. Sudheer Gupta

    Using C struct in Python** corrected

    Sudheer Gupta, Jun 7, 2006, in forum: Python
    Replies:
    0
    Views:
    303
    Sudheer Gupta
    Jun 7, 2006
  4. Dave Thomas
    Replies:
    3
    Views:
    131
    Satish Talim
    Dec 14, 2007
  5. Sergio Oliveira
    Replies:
    0
    Views:
    102
    Sergio Oliveira
    Feb 22, 2011
Loading...

Share This Page