sub read_template { my ($templfile, $hashref) = @_; my $fh = \ *DATA; # by way of open(...) local $/ = ''; # set the record terminator while ( <$fh> ) { last if /^\s*$/; # ignore trailing newline(s) chomp; # remove trailing terminator my ( $name) = /^\s*<\s*TEMPLATE\s+NAME="(.*)"\s*>\s*/i or die "data error in $templfile, chunk $."; $hashref->{ $name} = substr( $_, $+[ 0]); } } __DATA__