in reply to Hash of Array references

Hi,

This should give you a starting point:

#!/usr/bin/perl use strict; use warnings; use 5.010; use Carp; use Data::Dumper; use strict; use Data::Dumper; my %hash; while(my $line = <DATA>) { chomp $line; next if $line =~ m/^\s*#/; next if $line =~ m/^\s*$/; my ($number, $user, $comment) = split /\s+/, $line, 3; $hash{$number} = { number => $number, user => $user, comment => $comment, } } say Dumper(\%hash), "\n"; __DATA__ #Number User Comments 1234567 sam changed abc in the file. 5646542 john deleted asds in the file. 45656 me what a use name 535353 McA Supermonk *grin*

UPDATE: MidLifeXis had a very good question at Re: Hash of Array references. If you want to allow more than one entry per number you can collect them in an array. So change the lines

$hash{$number} = { number => $number, user => $user, comment => $comment, }

to

push @{$hash{$number}}, { number => $number, user => $user, comment => $comment, };

Regards
McA