I am trying to initialize a hash like this:
use strict;
my %hash =
(
key => <<END;
abc
def
END
,
another_key => 17
);
When I run perl -cw on this code, I get the error 'syntax error at hash-initialize-test.pl line 5, near ";"'.
Is there a way to use HEREIS notation (such as <<END;
) within hash initialization? If not, why not?
There are several simple workarounds, but I like to use HEREIS notation for multi-line strings because it is elegant and avoids introducing unnecessary variables.