open FILE, "< $file" or die "can't read $file: $!"; while () { push @extracted, /foo\d+/g; # just like /(foo\d+)/g }