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} .= $_; } }
In reply to Re: C idioms in Perl
by dwm042
in thread C idioms in Perl
by slife
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |