in reply to Re^2: Grouping unique lines into a file.
in thread Grouping unique lines into a file.

So does this do what you want?

use strict; use warnings; my %accounts; while ( <DATA> ) { push @{ $accounts{$1} }, $2 if /^(\d+)\s+(.+)/; } for my $k ( keys %accounts ) { open my $fh, '>', $k . 'txt' or die "Can't open '$k.txt': $!\n"; print $fh join "\n", @{ $accounts{$k} }; }

Update: Modified code slightly.