open (my $fh, "<", $file) or die "Can't open the file $file: "; while (<$fh>) { my $line = $_ if /\bWood\b/; chomp ($line); last if !$line; %hash2 = (%hash2 , (split(/;/, $line)),[1,0]); } print Dumper \%hash2;