Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
and I want to output:nick 5 nick 10 george 2 peter 3 george 14 nick 20
george:2,14 nick:5~~10~~20 peter:3
Now it produces weird results, can you please help me fix it? Perhaps I introduced a bug at some point and now I can't get it to work.use strict; use warnings; my %res; while (<>) { chomp; my ( $name, $rest ) = split /\t/; push @{ $res{$name} }, $rest; } for $a( sort keys %res ) { print "$a:". join( "~~", @{ $res{$a} } ); print "\n"; }
~~14ge:2 ~~20:5 peter:3
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Why is my code producing weird output?
by hv (Prior) on Aug 30, 2023 at 23:29 UTC | |
by BillKSmith (Monsignor) on Sep 01, 2023 at 18:49 UTC | |
by Anonymous Monk on Aug 31, 2023 at 09:41 UTC | |
|
Re: Why is my code producing weird output?
by GrandFather (Saint) on Aug 30, 2023 at 23:30 UTC | |
|
Re: Why is my code producing weird output?
by NetWallah (Canon) on Aug 30, 2023 at 23:23 UTC | |
by hv (Prior) on Aug 30, 2023 at 23:31 UTC | |
|
Re: Why is my code producing weird output?
by eyepopslikeamosquito (Archbishop) on Sep 03, 2023 at 09:46 UTC |