in reply to Getting columnwise substring from multiple lines
Update: I just noticed, that my first version fails if the real line length is not a multiple of the wanted length. So I had to put in the grep-regex :-(use Data::Dumper; my %hash; my $sub_length = '.' x 2; while (<DATA>) { chomp; # remove the chomp. It's unnecessary $hash{$.-1}=[ grep /$sub_length/o, split /($sub_length)/o ]; } print Dumper \%hash; __DATA__ ABDC EFGH
use Data::Dumper; my %hash; my $sub_length = '.' x 2; $hash{$.-1}=[ grep /$sub_length/o, split /($sub_length)/o ] while <DAT +A>; print Dumper \%hash; __DATA__ ABDCX EFGHX
|
|---|