Where did keyword2 go? Perhaps this was a design decision. If not, adding the line @{$hash{$currentkey}} = (); into the if( $inkey == 0 ) block does the trick.
P.S.: In order to make Data::Dumper print very nice output, pass it a hash reference, as in Dumper(\%hash). Then the output is as follows:
$VAR1 = { 'mykeyword3' => [ 'baz3', 'foo3', 'bar3' ], 'mykeyword2' => [], 'mykeyword1' => [ 'foo1', 'bar1' ], 'mykeyword4' => [ 'baz4' ] };
P.P.S.: Can some enlightened monk tell me the preferred way to "touch" an array (reference). That is, if I only want to clear an array if it doesn't already exist (see my @{$hash{$currentkey}} = (); addition above). The snippet push @{$hash{$currentkey}}; works but produces a Useless use of push with no values warning.
In reply to Re^2: searching data lines between keywords
by kaif
in thread searching data lines between keywords
by riz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |