in reply to Get string for a word in a file after some specific pattern compare
In other words, look for the string of interest (with some possible white space padding), and placeholder the 'word' that follows it up to the next white space. We break the loop if that exists, and the word will be in $1 from the regex. Otherwise, this should be null, and you'll know it's not there.while (<FILE>) { last if /TARGET\s?=\s?(\S*)\s/; } my $value = $1 || "not found";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(Ovid) Re(2): Get string for a word in a file after some specific pattern compare
by Ovid (Cardinal) on Mar 27, 2001 at 19:09 UTC | |
|
Re: Re: Get string for a word in a file after some specific pattern compare
by jbert (Priest) on Mar 27, 2001 at 19:42 UTC | |
|
Re: Re: Get string for a word in a file after some specific pattern compare
by chipmunk (Parson) on Mar 30, 2001 at 08:11 UTC |