in reply to Re^2: Adding text file data to hashes and array
in thread Adding text file data to hashes and array
Make the key by joining the first 2 fields. see splice and join
pojforeach my $line (@lines) { $line =~ s/^\s+//; my @elements = split /\s+/, $line; my $key = join '-',splice @elements, 0, 2; # 2 col key $hash{$key} = \@elements if length($key) > 0; # no blank keys }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Adding text file data to hashes and array
by Tigor (Novice) on Feb 15, 2019 at 07:10 UTC | |
by poj (Abbot) on Feb 15, 2019 at 07:58 UTC | |
by Anonymous Monk on Feb 15, 2019 at 12:05 UTC | |
by poj (Abbot) on Feb 15, 2019 at 13:01 UTC | |
by haukex (Archbishop) on Feb 15, 2019 at 08:35 UTC | |
by Tigor (Novice) on Feb 15, 2019 at 09:47 UTC | |
by haukex (Archbishop) on Feb 15, 2019 at 10:10 UTC | |
by Tigor (Novice) on Feb 15, 2019 at 11:10 UTC | |
|