in reply to reg exp

The following code will split each line that begins with one or more digits, assuming the elements are separated by spaces.
my $file = <STDIN>; chomp($file); if ($file =~ /\w+\.dat/) { open(DATOS, "$file") or die "error message"; while (<DATOS>) { push(@lines, $_) if /^\d/; } close DATOS; foreach my $line (@lines) { my @fields = split(/\s+/, $line); print "@fields"; # or whatever else you want to do } }