in reply to Re: Finding installed program version in Win32 registry
in thread Finding installed program version in Win32 registry

Thank you very much for your answer. This is a really useful technique. Regular expressions will never cease to amaze me.

This leaves just the question of checking just the required few applications. But I think I'll do it by pushing "Name: $1 Version $2" onto a separate list and then, I'll do something along the lines of:

foreach (@cleanlist) { if (/Adobe Reader.+Version\s+(.+)/) { $gathered_data{'AReaderVer'}=$1; } }

Maybe it's not the best way, but I think it should work. Thank you very much for your help.

Luke

Replies are listed 'Best First'.
Re^3: Finding installed program version in Win32 registry
by BrowserUk (Patriarch) on Apr 06, 2009 at 12:01 UTC

    Yes, that will work. But you could avoid the post-filtering step by hard coding the application name into the regex:

    while( <DATA> ) { m[ (?= ^ .*? DisplayName \s+ \S+ \s+ ( Adobe \s Reader \s 8 ) +\n ) (?= ^ .*? DisplayVersion \s+ \S+ \s+ ( [^\n]+ ) \n ) ]xsm and say "Name:$1 Version:$2"; }

    Now, the same information will be captured, but only when the name matches your requirements. If you want to capture the version information for several different apps but exclude any others, then just put the names of those you want to capture into an alternation:

    while( <DATA> ) { m[ (?= ^ .*? DisplayName \s+ \S+ \s+ ( Adobe \s Reader \s 8 | Another \s app \s description | Yet \s Another \s Application ) \n ) (?= ^ .*? DisplayVersion \s+ \S+ \s+ ( [^\n]+ ) \n ) ]xsm and say "Name:$1 Version:$2"; }

    But note: Due to the use of /x on the regex, you will need to explicitly signify any whitespace within the app descriptions using \s (or perhaps \s+).


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.