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.
# 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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |