You need to expand your regex to write the name of the DLL:
$infostring = lc($infostring); while ($infostring =~ /dll name: (\S+\.dll)/g) { print "found dll: $1\n"; }
\S+\.dll will match one or more characters without spaces, followed by ".dll", and parentheses collect the text matched inside them and store it in the variable $1 . (If you had more than one set of parentheses, the second will go at $2 , the third at $3 , etc.)
Edit: It looks like the input specification was changed by editing the question when I wrote my answer ... The above information would be for a single input line containing all the DLL names. In the new format, with each of them on a separate line, you would like to use:
while (my $infostring = <$input_filehandle>) { $infostring = lc($infostring); print "found dll: $1\n" if $infostring =~ /dll name: (\S+\.dll)/; }
No need to mess around with /g in a regular expression or iterate over matches if there arenβt multiple matches on the same line.
source share