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

I have web page written using cgi-perl script,where in i click a button OK, then it should open a seperate text file and has to show the results of the button click in that file.(it should not show in the same html file). And also the user should be able to save thet text file to his/her local disk. Is it possible to do using perl script? pls help me in this regard?

Replies are listed 'Best First'.
Re: Opening a text file
by davido (Cardinal) on Apr 01, 2004 at 07:34 UTC
    To answer your question, yes, it is possible to use Perl to write a script for the Common Gateway Interface that will be invoked when an HTML form's "OK" button is clicked. The Perl script can also open a seperate text file and manipulate it in many ways. And most browsers support allowing users to save text files to their own local disk, so long as you make it available to them in some way; via HTTP service, FTP, etc.

    If this is something that you need to get up and running quickly, and your current Perl programming skill level hasn't reached the point where you've learned how to open a file, you'll need to hire a programmer. On the other hand, if you have time and a thirst for knowledge, pick up a copy of Learning Perl (Published by O'Reilly and Associates), as well as CGI Programming with Perl, also published by O'Reilly.

    You may also find additional learning opportunities in the Perl POD (Plain Old Documentation). Start with perlintro, perl, perldoc -f open, perlopentut, CGI.pm, and the various entries under perlfaq.

    After you've begun reading these books and resources, you'll probably come up with specific questions to which we can offer specific answers. We're happy to help people who come here seeking Perl wisdom.

    Update: I noticed that you double-posted this question. Don't repost questions just because the first post doesn't show up in Seekers of Perl Wisdom immediately. Posts only show up there after a PerlMonk of high enough level "approves" the post, and sometimes that can take awhile; particularly for questions that lack evidence of prior research by the person asking the question.


    Dave

      I know how to open a text file. but my problem is ,as soon as user clicks a button,the perl script has to open a text file(notepad) in client's machine, not in server. It is easy to open a file in server's machine because the code is runing in server. Thank you for the fast response.
        print "Content-Type: text/plain\n\n"; print "the content of your text file here...";
        that should get you going.
        luckily it's not possible to force the client's machine to open notepad; besides that, on my machine there is no notepad.