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