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

Peace on All, and Mersey on me (bowing)
I have a number of PERL scripts that do various things; I use the command "print" to dump information on the screen (in DOS text mode). I am a bit fed up with this outdated method, can I send (or parse?? not sure how to word it) the out put to IE explorer, I Know I need to use some sort of (HTML) library, but I’m not quite sure which and how.
Basicall, regard the blank IE explorer page as the little DOS (cmd windows) and using the command “print or HTML equivalent command ” to show the text on the blank IE explorer page.
Thanking you<bowing>

Replies are listed 'Best First'.
Re: How to display text in IE?
by virtualsue (Vicar) on Jul 12, 2002 at 10:30 UTC
    It sounds as though you would like to learn how to do some CGI programming. 'perldoc CGI' at the command line for information on the CGI.pm module. There are some articles on this topic in the Tutorials section. Essentially, all you need to do is add
    use CGI qw(:standard); print header;
    to your programs. All print statements after this will go to the browser, so you'll need to decorate your output with appropriate HTML tags in order to make it look right.

    You will also need a webserver in order to make this work. See http://www.apache.org for an excellent free webserver which runs on most platforms.

Re: How to display text in IE?
by broquaint (Abbot) on Jul 12, 2002 at 10:10 UTC
    You could use the HTML::FromText module which should do basic HTML formatting for you, and if you're using a webserver to deliver the webpages make sure you use the CGI module for at least the basics such as header information. If we had further information about the format of the data you're printing out there's potentially many more modules that could be used to emulate the formatting faithfully.

    Update: there's also the HTML::TextToHTML module which looks to have a bunch of handy features.
    HTH

    _________
    broquaint

Re: How to display text in IE?
by Beatnik (Parson) on Jul 12, 2002 at 10:13 UTC
    If you want to show the output (like a report) in IE, you can basically just print HTML to output (and then redirect to a file) or print HTML to a file within Perl). If you want to do dynamic stuff (like forms, etc), you'd probably need a webserver too (and not to mention CGI.pm).

    PS: It's either perl or Perl, not PERL.

    Greetz
    Beatnik
    ...Perl is like sex: if you're doing it wrong, there's no fun to it.
Re: How to display text in IE?
by thunders (Priest) on Jul 12, 2002 at 11:13 UTC
    you don't have to display HTML in a browser. Nearly all browsers can handle plain text. just print the MIME type in the header.
    use CGI qw(:standard); print header("text/plain"); print "text";
    but that's from within a cgi, from the command line a script like this will work:
    use Cwd; $text='my text'; open(FILE,'>stuff.txt'); print FILE $text; close (FILE); system('iexplore '.cwd.'\stuff.txt');"
    works if iexplore is on your path if not you can add directories to you PATH like so(Win ME example)
    set PATH=%PATH%;C:\Progra~1\Intern~1;
Re: How to display text in IE?
by Juerd (Abbot) on Jul 12, 2002 at 11:16 UTC

    Use a server side (CGI or mod_perl) script, and have it output the appropriate headers and html, as others have already pointed out.

    Alternatively, if you don't want to use a webserver and it is just used locally, you can write the html to a temporary file.

    my $tempfile = 'generate a nice filename based on system settings'; open my $fh, '>', $tempfile or die "Can't open '$tempfile' for output: + $!"; print $fh '<html><head><title>Test page</title></head><body><b>Hello, +World!</b></body></html>'; close $fh; system( start => $tempfile ); unlink $tempfile or die "Cannot delete '$tempfile': $!";

    - Yes, I reinvent wheels.
    - Spam: Visit eurotraQ.
    

Re: How to display text in IE?
by Parham (Friar) on Jul 12, 2002 at 14:37 UTC
    i would probably go with what the other monks suggested, but here's something simple as well. I'll assume that your text file is just that, a simple text file with line returns. to output it, try this:
    print "Content-type: text/html\n\n"; print <<"EOF"; <HTML> <HEAD> <TITLE>textfile</TITLE> </HEAD> <BODY> <PRE> $textfile </PRE> </BODY> </HTML> EOF exit;
    note the 'pre' tags in there. \n's at the end of lines are actually processed within those so your text file will output the way you want it to :).
Re: How to display text in IE?
by BorgCopyeditor (Friar) on Jul 12, 2002 at 19:03 UTC

    If you're really ambitious, you could try Win32::OLE and have your scripts spawn IE and dump their output to it whenever they run. (At least, I think one could do that.)

    BCE
    --Your punctuation skills are insufficient!