in reply to Re^2: Finding installed program version in Win32 registry
in thread Finding installed program version in Win32 registry
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+).
|
|---|