Dear monks,
as a newbie about to switch from Windows Visual Basic to perl I seek your wisdom on how to migrate from the below VB browser automation that allowed me to redirect program output from VB to a (IE) browser window with interspersed HTML formatting via a VB class (see code snippet below).
After instantiation, it opened up a new browser window, and allowed to programmatically send text output to this window with the benefit of utilizing the browser's HTML display formatting capabilities, e.g. sending <B>message</B> etc.
This "browser-based console" was very handy, as it automatically took care of line wraps when resizing the browser window, automatically added scroll bars allowing to view earlier text sent to the window, and made font sizing and font attribute handling very easy by the interspersed HTML tags, way beyond the possibilities of a simple ASCII text console to display the output of a perl program.

Is there a way to have a similar display capability in perl,, i.e. to send a perl program's output to a console window with the same formatting features a browser (nowadays Chrome, Firefox, ..) window would allow, and also have a "tail -f"-like realtime view, i.e. not writing everything to a HTML file and then displaying the written content afterwards?
Maybe an alternative approach might be to re-direct the perl output via interprocess communication utilizing "server-sent events" which will then be displayed by an eventlistener javascript program in a browser window, but this seems to be an all too sophisticated solution just to have a "tail -f"-like console that also features HTML formatting.

Thanks in advance for your kind and lenient feedback ... Cheers - Rob
# VB-code to be migrated to perl ... Private objIe As SHDocVw.InternetExplorer Private objIeWinDoc As Object 'HTMLDocument ... Public Property Let width(intWidth As Integer) objIe.width = intWidth End Property Public Property Let height(intHeight As Integer) objIe.height = intHeight End Property ... Private Sub Class_Initialize() If objIe Is Nothing Then Set objIe = CreateObject("InternetExplorer.Application") End If If objIe Is Nothing Then Err.Raise "error: could not spawn IE" End If objIe.Navigate ("about:blank") objIe.Visible = True objIe.ToolBar = False objIe.StatusBar = False Do While (objIe.Busy): Loop Set objIeWinDoc = objIe.Document objIeWinDoc.open End Sub Private Sub Class_Terminate() objIeWinDoc.Close objIe.Quit Set objIe = Nothing End Sub Sub WriteText(strText As String, _ Optional bolBold As Boolean, _ Optional bolCursive As Boolean, _ Optional bolUnderline As Boolean, _ Optional intFontSize As Byte, _ Optional strFontColor As String) ... If intFontSize <> 0 Then objIeWinDoc.Write "<font size =" & intFontSi +ze & ">" If strFontColor <> "" Then objIeWinDoc.Write "<font color =" & strFon +tColor & ">" If bolBold Then objIeWinDoc.Write "<B>" If bolCursive Then objIeWinDoc.Write "<I>" If bolUnderline Then objIeWinDoc.Write "<U>" objIeWinDoc.Write strText If bolUnderline Then objIeWinDoc.Write "</U>" If bolCursive Then objIeWinDoc.Write "</I>" If bolBold Then objIeWinDoc.Write "</B>" If strFontColor <> "" Then objIeWinDoc.Write "</font>" If intFontSize <> 0 Then objIeWinDoc.Write "</font>" End Sub

In reply to "tail -f"-like Console Output to Browser with HTML Formatting by rstr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.