use strict; use warnings; open my $regFH, q{<}, \ <<'EOD' or die qq{open: << HEREDOC: $!\n}; Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall] "DisplayName"="" "UninstallString"="C:\\PROGRA~1\\CISCOS~1\\VPNCLI~1\\Profiles\\PROGRA~1\\CISCOS~1\\VPNCLI~1\\profiles\\UNWISE.EXE C:\\PROGRA~1\\CISCOS~1\\VPNCLI~1\\Profiles\\PROGRA~1\\CISCOS~1\\VPNCLI~1\\profiles\\INSTALL.LOG" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\AddressBook] @="" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Adobe SVG Viewer] "DisplayName"="Adobe SVG Viewer 3.0" "DisplayVersion"=" 3.0" "DisplayIcon"="C:\\Program Files\\Common Files\\Adobe\\SVG Viewer 3.0\\Uninstall\\SetupRsrc.dll,-200" "VersionMajor"=dword:00000003 "VersionMinor"=dword:00000000 "InstallLocation"="C:\\WINDOWS\\system32\\Adobe\\SVG Viewer 3.0" "UninstallString"="C:\\Program Files\\Common Files\\Adobe\\SVG Viewer 3.0\\Uninstall\\Winstall.exe -u -fC:\\Program Files\\Common Files\\Adobe\\SVG Viewer 3.0\\Uninstall\\Install.log" "UninstallDir"="C:\\Program Files\\Common Files\\Adobe\\SVG Viewer 3.0\\Uninstall" "Publisher"="Adobe Systems, Inc." "RegCompany"="Adobe Systems Inc" "URLInfoAbout"="http://www.adobe.com/" "URLUpdateInfo"="http://www.adobe.com/svg/main.html" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Artemis 7.2.1 ODBC] "NoRemove"=dword:00000001 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Standalone] "UninstallString"="C:\\WINDOWS\\IsUninst.exe -f\"C:\\Program Filesone.isu\"" "DisplayName"="This is-not SHOWING" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\exampler] "DisplayName"="Example Display Name" "UninstallString"="c:\\applications\\uninst.exe" "DisplayVersion"="v7.5.2" "URLInfoAbout"="http://something.htm" "Publisher"="NOT caught" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Branding] "QuietUninstallString"="Rundll32 IedkCS32.dll,BrandCleanInstallStubs" "RequiresIESysFile"="100.0" EOD # For clarity, use hex escapes for certain characters in the following # regular expression. # \x22 => " # \x5b => [ # \x5c => \ # \x5d => ] my $rxParseData = qr {(?xs) # Use extended syntax and . matches \n \A # Begining of string (?-s: # Grouping, switch off . matches \n # inside grouping \x5b HKEY # [HKEY .* \x5c # 0 or more of any character except # \n, greedy then \ ( [^\x5d]+ ) # Capture 1 or more non-] ) # Close grouping (?= # Open +ve look-ahead .*? \x22 # any character, non-greedy then " DisplayName # DisplayName attribute \x22 = \x22 # "=" ( [^\x22]* ) # Capture 0 or more non-" )? # Close +ve look-ahead, 0 or 1 of (?= # Open +ve look-ahead .*? \x22 # any character, non-greedy then " DisplayVersion # DisplayVersion attribute \x22 = \x22 # "=" ( [^\x22]* ) # Capture 0 or more non-" )? # Close +ve look-ahead, 0 or 1 of (?= # Open +ve look-ahead .*? \x22 # any character, non-greedy then " Publisher # Publisher attribute \x22 = \x22 # "=" ( [^\x22]* ) # Capture 0 or more non-" )? # Close +ve look-ahead, 0 or 1 of }; { local $/ = q{}; while( <$regFH> ) { next unless m{$rxParseData}; my $item = $1; my $displayName = cleanCapture( $2 ); my $displayVersion = cleanCapture( $3 ); my $publisher = cleanCapture( $4 ); print qq{Software Item - $item\n}, qq{ Name : $displayName\n}, qq{ Version : $displayVersion\n}, qq{ Publisher: $publisher\n\n}; } } close $regFH or die qq{close: << HEREDOC: $!\n}; sub cleanCapture { my $capture = shift; return defined $capture ? $capture ? do { local $_ = $capture; s{^\s+}{}; s{\s+$}{}; $_; } : qq{Empty field!} : q{Not found!}; } #### Software Item - Uninstall Name : Empty field! Version : Not found! Publisher: Not found! Software Item - AddressBook Name : Not found! Version : Not found! Publisher: Not found! Software Item - Adobe SVG Viewer Name : Adobe SVG Viewer 3.0 Version : 3.0 Publisher: Adobe Systems, Inc. Software Item - Artemis 7.2.1 ODBC Name : Not found! Version : Not found! Publisher: Not found! Software Item - Standalone Name : This is-not SHOWING Version : Not found! Publisher: Not found! Software Item - exampler Name : Example Display Name Version : v7.5.2 Publisher: NOT caught Software Item - Branding Name : Not found! Version : Not found! Publisher: Not found!