in reply to Read File In Four-Line Chunks / TMTOWTDI / Golf
use strict; use warnings; use Tie::File; use Data::Dumper; my @file; my @key = qw(name address phone fax); tie @file, 'Tie::File', 'address.txt' or die $!; my @record = map { my %hash; @hash{@key} = @file[$_..$_+4-1]; \%hash; } range(0,$#file,4); print Dumper \@record; sub range {grep!(($_-$_[0])%($_[2]||1)),$_[0]..$_[1]}
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
|---|