in reply to Non-CGI perl scripts on a web server?

There's text/plain if you just want to return a text document. Other file types include image/png.

The Content-type header takes a MIME type. There's a list of many of those at Wikipedia. Many of those are valid and understood as document types by popular web browsers. Some require external applications be triggered for rendering. A few of them are more appropriate to other uses such as documents being sent back to the web server or messages parsed by email clients.

There are also XMLHTTPRequest and related methods for JavaScript. If you want to just return a notification in the current page, you could return plaintext, HTML, JSON, or XML (or, indeed, other things) and update the current page using JavaScript to show the results. Libraries like jQuery make this simple.

Replies are listed 'Best First'.
Re^2: Non-CGI perl scripts on a web server?
by 5plit_func (Beadle) on Feb 24, 2015 at 01:01 UTC

    The other way to out put a header would be:

    use CGI; my $header = new CGI; print $header->header();

    I hope this helps

      And at least a few more ways of which I don’t doubt mr_mischief was aware. :P

      ~>perl -MCGI -e 'print CGI->header' Content-Type: text/html ~>perl -MCGI -e 'print CGI->header("text/plain")' Content-Type: text/plain ~>perl -MCGI=:standard -e 'print header("text/plain; charset=UTF-8")' Content-Type: text/plain; charset=UTF-8

      (Update: chopped p rint fixed.)

      I don't recall anyone asking nor answering about alternative ways to output headers. The question I answered was about alternate values for the header.