open my $f, '<', 'fname.txt'; my @f; push @f, /(\d+)/g while <$f>;