Kailua362 has asked for the wisdom of the Perl Monks concerning the following question:

Aloha, I am new to PERL and CGI. I can not understand why I get different results between my MAC and a PC. The MAC displays the Teacher Input I want, while the PC includes the Submit Button. I just want one field. Any and all suggestions are welcome.
#!/usr/local/bin/perl require "subparseform.lib"; &amp;amp;Parse_Form; print "Content-type: text/html\n\n"; print "<body bgcolor=#ffffcc>"; print "<p><font color=#006633 size=5><div align=center>Lanikai Element +ry Teacher Input </div align=center></font><br><font color=#006633 si +ze=4><div align=center>Career and Life Skills Grade 6</div align=cen +ter></font></p>"; foreach $key (sort keys(%formdata)) { if ($formdata{$key} ne ""){ print "<P><i>Your Teacher input is:</i> <B>$formdata{$key}</B>\n"; } } print "\n<p><font color=#FF0000 size=4><div align=center>You may now c +lose this window</div align=center></font></p>"; print"</body bgcolor>";
http://216.97.42.123/lanikai/test/K-3/index_K-3.html Mahalo Joseph Guillaume

guillaum@pixi.com

http://www.pixi.com/~guillaum

Replies are listed 'Best First'.
Re: Differences between MAC and PC
by dorko (Prior) on Mar 30, 2002 at 18:15 UTC
    Kailua362,

    A quick seach on Google leads me to think you've bought a copy of Perl & CGI for the World Wide Web: Visual QuickStart Guide. The author seems to mention CGI.pm, then proceeds to use a hand rolled parser, namely subparseform.lib. Furthermore, the author admits that subparseform.lib is less than optimal in that it doesn't handle "special characters" (e.g. @ $ < >) very well.

    I'm hoping the author is using a simple CGI parser for illustrative reasons only and recommends using CGI.pm for everything else. If the author doesn't stress CGI.pm, I'd suggest taking a look at Ovid's "Web Programming Using Perl" Course. It's all online and it's free.

    CGI.pm is the industry standard, is a part of the standard Perl installation, and most importantly it is safe and it works.

    Aloha and Cheers!

    Brent

    -- Yeah, I'm a Delt.

    Update: For a more complete discussion of why one should avoid using something besides CGI.pm, you should really look at this thread: use CGI or die.

      Aloha, Yes, you are correct about using the Visual Quickstart Guide Book. The book had a site that down loaded subparse_form.lib. Is there a better alternative to subparse_form.lib? Were can I download a better version of the CGI. If only I could parse data I think I would be well on my way. Mahalo. Joseph W. Guillaume
        There's a guide to installing modules by tachyon, but I'm guessing CGI.pm already installed on your system.

        If your running the ActiveState version of Perl on a Windows machine, you can quickly see what's installed by opening a DOS window and typing 'ppm'. Once PPM is running, do a 'verify' and that will tell you what packages you have installed and wether or not they are up to date. You can also do a 'help' to get the options for PPM.

        If I've been clear as mud, let me know and I'll try to clear things up.

        Cheers!

        Brent

        -- Yeah, I'm a Delt.

      The first Perl book I ever read was the first edition of the book you mention. I'm still recovering.

      That said, looking briefy at the page you linked to it does mention the use of strict, cgi.pm, taint mode, and warnings. So perhaps the author has picked up a little Perl since writing the first edition and the second edition won't encourage such bad practices. There are of course safer alternatives when it comes to Perl books :).

Re: Differences between MAC and PC
by chromatic (Archbishop) on Mar 30, 2002 at 17:12 UTC
    It's hard to say specifically, but my guess is that subparseform.lib is buggy. (That's a reasonable guess anyway.) You can achieve the same effect with:
    #!/usr/local/bin/perl -w use strict; use CGI qw(:standard); print header(); print "Whatever HTML here...\n"; foreach my $key (sort param()) { if (param($key)) { print "<P><i>Your Teacher input is:</i><B>", param($key), "</B +>\n"; } }
    As web browsers generally miss standards by margins exceeded only by form parsers, it may be a line ending problem, or a character encoding problem. It's better to stick with CGI.pm in this case, as it handles just about anything anyone could ever throw at it.