in reply to C idioms in Perl

I think jdporter has done a terrific job of analyzing this piece of code, but the one thing I see is that there is no need to load data you don't need. Just check to see that the data are between the template tags and refuse to load otherwise.

my $hash_key = undef; while (<>) { if ( /^\s*<\s*TEMPLATE\s+NAME="(.*)"\s*>/i ) { $hash_key = $1; $hashref->{$hash_key} = ''; } elsif ( /^\s*<\s*\/\s*TEMPLATE\s*>/i ) { $hash_key = undef; } elsif (defined($hash_key)) { $hashref->{$hash_key} .= $_; } }