use strict; use XML::Writer; my $xml = XML::Writer->new(DATA_MODE => 1, DATA_INDENT => 4, UNSAFE => 1); to_xml(); sub new_tag { my $tag = shift; $xml->startTag($tag); while () { chomp; if (/^\s*Begin\s+\S+\s+(\w+)\s*$/) { new_tag($1); } elsif (/^\s*End\s*$/) { $xml->endTag($tag); return; } elsif (/^\s*(\w+)\s*=\s*\"?(.+)\"?\s*$/) { $xml->startTag($1); $xml->characters($2); $xml->endTag($1); } } } sub to_xml { while () { chomp; new_tag($1) if (/^\s*Begin\s+\S+\s+(\w+)\s*$/); } } __DATA__ VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 6465 ClientLeft = 60 ClientTop = 345 ClientWidth = 11715 LinkTopic = "Form1" ScaleHeight = 6465 ScaleWidth = 11715 StartUpPosition = 3 'Windows Default Begin VB.Frame main_frame Caption = "Frame1" Height = 8775 Left = 0 TabIndex = 0 Top = 360 Width = 10695 Begin VB.TextBox sub_category_creator_text Height = 285 Left = 7320 TabIndex = 8 Top = 1680 Width = 1815 End Begin VB.TextBox category_creator_text Height = 285 Left = 2040 TabIndex = 6 Top = 1680 Width = 2295 End Begin VB.TextBox reference_number_text Height = 285 Left = 2040 TabIndex = 4 Top = 1200 Width = 2295 End Begin VB.TextBox title_text Height = 285 Left = 2040 TabIndex = 2 Top = 600 Width = 4695 End Begin VB.Image sub_category_picker_image Height = 375 Left = 9360 Top = 1680 Width = 375 End Begin VB.Label sub_category_creator Alignment = 1 'Right Justify Caption = "Sub Category (Creator)" Height = 375 Left = 5520 TabIndex = 7 Top = 1680 Width = 1695 End Begin VB.Image creator_picker_image Height = 375 Left = 4440 Top = 1680 Width = 375 End Begin VB.Label category_creator Alignment = 1 'Right Justify Caption = "Category (Creator)" Height = 375 Left = 360 TabIndex = 5 Top = 1680 Width = 1575 End Begin VB.Label reference_number Alignment = 1 'Right Justify Caption = "Reference Number" Height = 375 Left = 360 TabIndex = 3 Top = 1200 Width = 1575 End Begin VB.Label TitleLabel Alignment = 1 'Right Justify Caption = "Title*:" Height = 375 Left = 360 TabIndex = 1 Top = 600 Width = 1575 End End #### Form1" 6465 60 345 11715 Form1" 6465 11715 3 'Windows Default Frame1" 8775 0 0 360 10695 285 7320 8 1680 1815 285 2040 6 1680 2295 285 2040 4 1200 2295 285 2040 2 600 4695 375 9360 1680 375 1 'Right Justify Sub Category (Creator)" 375 5520 7 1680 1695 375 4440 1680 375 1 'Right Justify Category (Creator)" 375 360 5 1680 1575 1 'Right Justify Reference Number" 375 360 3 1200 1575 1 'Right Justify Title*:" 375 360 1 600 1575