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
In reply to Re: key and values help
by davido
in thread key and values help
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |