Perl error Use of uninitialized value $_ in substitution (s///)
<p>Greeting I try to read a file into hash of hash following this tutorial.</p>

<p><a href="http://docstore.mik.ua/orelly/perl/prog3/ch09_04.htm" rel="nofollow">http://docstore.mik.ua/orelly/perl/prog3/ch09_04.htm</a></p>

<p>My text input file is</p>

<pre><code>event_a1_x1: email1=xxx@gmail.com email2=yyy@gmail.com email1_cnt=3 
event_a1_x2: email1=xxx@gmail.com email2=yyy@gmail.com email1_cnt=3 
event_b2_y1: email1=xxx@gmail.com email2=yyy@gmail.com email1_cnt=3 
event_b2_y2: email1=xxx@gmail.com email2=yyy@gmail.com email1_cnt=3 
event_c3_z1: email1=xxx@gmail.com email2=yyy@gmail.com email1_cnt=3 
event_c3_z2: email1=xxx@gmail.com email2=yyy@gmail.com email1_cnt=3
</code></pre>

<p>My code is</p>

<pre><code>#!/usr/bin/perl
use strict;
use warnings;

my $file = $ARGV[0] or die "Need to get config file on the command line\n";

open(my $data, '&lt;', $file) or die "Could not open '$file' $!\n";

my %HoH;
#open FILE, "filename.txt" or die $!;
my $key;
my $value;
my $who;
my $rec;
my $field;

while ( my $line = &lt;$data&gt;) {
    print $line;
    next unless (s/^(.*?):\s*//);
    $who = $1;
    #print $who;
    $rec = {};
    $HoH{$who} = $rec;
    for $field ( split ) {
        ($key, $value) = split /=/, $field;
        $rec-&gt;{$key} = $value;
    }
}
</code></pre>

<p>I keep getting this error...</p>

<pre><code>Use of uninitialized value $_ in substitution (s///) at ./read_config.pl line 18, &lt;$data&gt; line 1. 
</code></pre>