in reply to Flawless Script problems?

Comment out use CGI; and it will work as you expect.

One of the first things CGI.pm does on Win32 is binmode STDIN, STDOUT and STDERR. A side effect of binmode is that perl no longer does its transparent line-end adjustments.

Try this little demo:

use strict; use warnings; print "Just hit enter (before CGI)"; my $var = <STDIN>; print ":", ord $_, ":" for (split //, $var); print "\nChomping\n"; chomp $var; print ":", ord $_, ":" for (split //, $var); print "\n"; eval 'use CGI;'; print "Just hit enter (after CGI)"; $var = <STDIN>; print ":", ord $_, ":" for (split //, $var); print "\nChomping\n"; chomp $var; print ":", ord $_, ":" for (split //, $var); __END__ output: Just hit enter (before CGI) :10: Chomping Just hit enter (after CGI) :13::10: Chomping :13:

As you see, there is a carriage return left after using CGI that isn't there before CGI.

Replies are listed 'Best First'.
Re: Re: Flawless Script problems?
by sulfericacid (Deacon) on Mar 13, 2003 at 20:39 UTC
    + 1000000 votes for you (if i had that many that's how many you'd get, bad sadly I only have two left :( ). I took the line off and it runs like it should have the entire time! I have two questions for you though.

    If programming in commandline will you ever need to use CGI.pm then? Sorry if these seems stupid but I just stopped working on the web so I can learn perl quicker by debugging on my own system.

    If this is to be run on linux would they need to add use CGI; or will it run for them as well?

    Thanks so much!!! You are a life saver!!!!!!!!!

    "Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

    sulfericacid

      CGI is for parsing the environment passed to a web application. It handles parsing of variables returning from forms and other information passed to the application from the web server. It can also be used to assist in HTTP header and HTML generation. If your application is not being run by a web server in response to a browser request, you don't need to use CGI.

      --- print map { my ($m)=1<<hex($_)&11?' ':''; $m.=substr('AHJPacehklnorstu',hex($_),1) } split //,'2fde0abe76c36c914586c';
        Thanks for clearing that up, pfaut!

        "Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

        sulfericacid