in reply to Re: Get string for a word in a file after some specific pattern compare
in thread Get string for a word in a file after some specific pattern compare
Since the while block has been exited, by the time you check $1 it contains the value it held before the while block was executed.$<digits> Contains the subpattern from the corresponding set of parentheses in the last pattern matched, not counting patterns matched in nested blocks that have been exited already. (Mnemonic: like \digits.) These variables are all read-only.
Try this instead:
my $value = 'not found'; while (<FILE>) { $value = $1, last if /TARGET\s?=\s?(\S*)\s/; }
|
|---|