Once your regex succeeds, $1 holds its value until the next time the regex *succeeds*. You want to conditionalize your use of $1 to only when the regex succeeds, not to when $1 is true:
while (my $line = <FH>) { next unless $line =~ m/\s([\w ]+? PRIMARY SCHOOL)/; push (@schools, $1); }
In reply to Re: Why repeated matches...
by Anonymous Monk
in thread Why repeated matches...
by kiat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |