Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use strict;
- use locale;
- use Data::Dumper;
- open FH,$ARGV[0]||die"$!\n";
- my @AoH = {};
- my $rec = {};
- while ( <FH> ) {
- chomp;
- #for $field ( split(/,/ ) {
- #($key, $value) = split /,/, $field;
- my ($key, $value) = split /,/;
- push @{$rec->{$key}}, $value;
- #}
- #push @AoH, $rec;
- }
- print Dumper $rec;
- #@AoH = sort keys $rec; # Experimental keys on scalar is now forbidden at hash_&_array_reference.pl line 23.
- @AoH = sort keys %$rec;
- print Dumper \@AoH;
- #while ( <FH> ) {
- # push @AoH, { split /[\s=]+/ };
- #}
- __END__
- #
- # Input:
- #
- aaaa,4645
- aaaa,7317
- aaaa,7155
- aaaa,7674
- bbbb,183
- bbbb,8830
- bbbb,8227
- ccc,4065
- ccc,9486
- ccc,5968
- ccc,7428
- ccc,6868
- #
- # Result:
- #
- $VAR1 = {
- 'ccc' => [
- '4065',
- '9486',
- '5968',
- '7428',
- '6868'
- ],
- 'bbbb' => [
- '183',
- '8830',
- '8227'
- ],
- 'aaaa' => [
- '4645',
- '7317',
- '7155',
- '7674'
- ]
- };
- $VAR1 = [
- 'aaaa',
- 'bbbb',
- 'ccc'
- ];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement