in reply to Sort alphabetically from file
Using Hash of Arrays, is simple enough.
EDIT: changed up code slightlyuse strict; use warnings; my %hash; while (<DATA> =~ /(\d)\s+(\d)\s+(\d)\s+(\w+)/){ push @{$hash{$4}}, $1, $2, $3; } print "@{$hash{$_}}[0..2] $_\n" for sort keys %hash; __DATA__ 1 2 3 delta 1 2 3 apricot 1 2 3 charlie 1 2 3 bravo 1 2 3 echo 1 2 3 fox
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Sort alphabetically from file
by edujs7 (Novice) on Jun 15, 2019 at 08:33 UTC | |
by soonix (Canon) on Jun 15, 2019 at 09:50 UTC | |
by edujs7 (Novice) on Jun 15, 2019 at 10:24 UTC | |
by james28909 (Deacon) on Jun 15, 2019 at 11:19 UTC | |
by haukex (Archbishop) on Jun 16, 2019 at 09:11 UTC | |
| |
by bliako (Monsignor) on Jun 15, 2019 at 09:29 UTC | |
by LanX (Saint) on Jun 22, 2019 at 23:21 UTC |
In Section
Seekers of Perl Wisdom