http://qs321.pair.com?node_id=11123130


in reply to Applying regex to each line in a record.

You need to remember the current header (or the current section).
#!/usr/bin/perl use warnings; use strict; my %hash; my $header; while (<>) { if (my ($h) = /^(.*):$/) { $header = $h; } elsif (my ($k, $v) = /^(.*):(.*)$/) { $hash{$header}{$k} = $v; } } use Data::Dumper; print Dumper \%hash;
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]