You need to extend your regex to capture the name of the DLL:
$infostring = lc($infostring);
while ($infostring =~ /dll name: (\S+\.dll)/g) {
print "found dll: $1\n";
}
The \S+\.dll
will match one or more non-whitespace characters followed by ".dll" and the parentheses will collect the text matched inside them and store it in the variable $1
. (If you had more than one set of parentheses, the second would go into $2
, the third to $3
, etc.)
Edit: Looks like the input specification was changed by an edit to the question while I was writing my answer... The above would be for a single input string containing all DLL names. Under the new format, with each one on a separate line, you'd instead want 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 with /g
on the regex or looping over matches if there won't be multiple matches in a single line.