If the File::Slurp module is not available, I find the
do { local $/; <> }
expression preferable due to narrower, thus better controlled, scoping. (In original reply, lexical my %hash; was defined within, accessed from outside of a block.)
>perl -wMstrict -le
"use Data::Dumper;
;;
my %hash =
map { chomp; $_ => '1' } split /(\s+|\W+)/, do { local $/; <> };
;;
print Dumper \%hash;
" new_ib1.txt | head -10
$VAR1 = {
'' => '1',
'BIG' => '1',
'you' => '1',
'model' => '1',
'NOT' => '1',
',' => '1',
'understand' => '1',
'MY' => '1',
'2' => '1',
|