http://qs1969.pair.com?node_id=380840


in reply to key and values help

Well, is the input in the form of one big string, or is it in some other form? I'll assume it's a string.

my $input = "log1 123 log1 233 log1 223 log2 465 log2 231 log2 456"; my @items = split /\s+/, $input; my %groups; while ( @items ) { push @{$groups{ +shift( @items ) }}, shift( @items ); } print "$_ @{$groups{$_}}\n" foreach sort keys %groups;

Dave