On 7/25/06, Rob Dixon <[EMAIL PROTECTED]> wrote:
my @values; while (<$fh>) { next unless /(\S+)\s*=\s*(\S+?)\s*;?/; push @values, $1, $2; } @values; }
Be careful with this. With regex, it's (usually) better to seach for the things you want than to try to exclude the things you don't. There are a whole lot of things in \S that we probably don't want here. If you want numbers, look for numbers. Because if there's a typo in the file, Perl will quite happily go on and use non-numeric matches of \S in subsequent arithmatic, yeilding unexpected and difficult to debug results, e.g. $a = "F"; print $a + 0; Using $1 and $2 in this context is a bit redundant, too. instead, try something like my ($condition, $value) = /\s*(\w+)\s*=\s*(\d+)/; HTH, -- jay -------------------------------------------------- This email and attachment(s): [ ] blogable; [ x ] ask first; [ ] private and confidential daggerquill [at] gmail [dot] com http://www.tuaw.com http://www.dpguru.com http://www.engatiki.org values of β will give rise to dom!