Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Buffered STDIN

by Sojourner (Initiate)
on Jul 18, 2001 at 17:25 UTC ( [id://97641]=perlquestion: print w/replies, xml ) Need Help??

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

Hello all. This one has me stumped. I am running a simple script to interface with a local executable. When I post form data and run &ReadParse; it seems that STDIN is remembering all the previous inputs as well, because I am getting variable values like:

"H:\ConfigFile.cppH:\DateOps.cppH:\DarkCal.cpp"

Very messy.

This page worked fine on my local NT machine, but when I try it over the network on an NT server it gives me this mess. Is there some 'unbuffer' setting that I am forgetting?

Thanks so much in advance for your help.

Sojourner

Replies are listed 'Best First'.
Re: Buffered STDIN
by HyperZonk (Friar) on Jul 18, 2001 at 17:31 UTC
    To turn off buffering, you simply set $| to a non-zero value, i.e. $|++;. But honestly, I don't think that's your problem. Can we see a code sample, please?
      Sorry if I wasn't clear - I'm new here.

      I have a form on which there is a file input type and a hidden input type. The user browses and selects a file, then clicks a submit button. The hidden input field holds the file path. I then run the code; the following part is the relevant problem code:

      &ReadParse(*input); $path = "$input{'input2'}"; print <<"ending_print_tag"; <HTML> <HEAD><TITLE>Code Submitted</TITLE></HEAD> <BODY> <H2>File: $path has been successfully submitted!</H2><BR> </BODY> </HTML> ending_print_tag

      When I print the $path variable I not only get the path to the present file I have submitted, but the paths to other files I have previously submitted (see my first post for an example)... In other words, the input is not being cleared. After far too much fiddling I think I have narrowed it down to STDIN.

      Somehow STDIN is keeping all my previous inputs plus the new ones and I have no idea how to prevent that.

      TKS again and I hope this is clearer,

      Sojourner

        From the look of the code you've put there, it looks like the problem is occurring in the ReadParse sub.
        Can you enlighten me as to what happens in this sub?
        Perhaps posting the whole code section pertaining the original setup of the input typeglob, and the code that comprises the ReadParse sub?
        One of the things you'll get used to on PM is that the more code you post, the easier it is for people to spot interaction problems and oversights... Don't worry about seeming silly by having some HUGE oversight in the code.. I make enough gaffes on here, and the guys are polite enough to smile quietly and correct my oversights..

        Cheers

        Malk
Re: Buffered STDIN
by Cirollo (Friar) on Jul 18, 2001 at 17:59 UTC
    Maybe you're passing old input back in through a hidden form field? Hard to tell without a code sample

    Also, you really should be using CGI.pm. Take a look at the node use CGI or die;

Re: Buffered STDIN
by Sifmole (Chaplain) on Jul 18, 2001 at 18:06 UTC
    Not much to go on, but you might want to check that your URL is not growing, like...
    http://foo.cgi?name=foo&pwd=bar http://foo.cgi?name=foo&pwd=bar?name=foo&pwd=bar http://foo.cgi?name=foo&pwd=bar?name=foo&pwd=bar?name=foo&pwd=bar
    That can happen if your FORM action is not set up properly.

      I am using the POST method, so I don't think the growing URL is the problem.

      Since there are only one or two user inputs, I am also not sure that CGI.pm would we worthwhile. I am quite new and inexperienced with Perl, however, so what do I know?

      Sojourner

        Thank you all for your input and help! I think I have solved the problem. I have switched to using CGI.pm - Cirollo, you mentioned this - instead of cgi-lib.pl to call the ReadParse sub and now it works properly.

        You guys have a great place here at PM! Keep up the good work and God bless.

        Sojourner

        CGI.pm is generally quite worthwhile. The regularity with which its use is recommended by the knowledgable people of this site and others should give you some thought.

        Are you using a persistent Perl app? FastCGI, mod_perl, or some-such? You could be having a situation where you are not clearing the input buffer you are reading from. Using CGI would solve that problem.

A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://97641]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-19 19:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found