in reply to How do I remove duplicate numeric elements of an array and preserve alphabetic elements?
use strict; use warnings; use Autodie; open my $FH, '<', 'jzelkowsz.dat'; my %data; while (my $pair = do{ $/ = ', ';<$FH>}) { my ($numeric, $alpha) = split qr/,/, $pair; push @{$data{$numeric}}, $alpha; } foreach my $num (sort keys %data) { $" = ','; $\ = "\n"; print "$num|@{$data{$num}}"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How do I remove duplicate numeric elements of an array and preserve alphabetic elements?
by jzelkowsz (Novice) on Jun 07, 2018 at 13:25 UTC |