Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Fail to give this:#!/usr/bin/perl -w use strict; use Data::Dumper; my $key; my %hoa; while ( <DATA> ) { my @aoa; next if (/^\s+/); if ( /^SET/ ) { my @KEY = split (/[\s:]/,$_); $key = $KEY[2]; } elsif (/^\d/) { my @INST = split(/,/,$_); push @aoa, [ @INST ]; } $hoa{$key} = [@aoa]; } print Dumper \%hoa ; __DATA__ SET: SET1 0,100,BOOK 1,150,PENCIL ==== SET: SET2 2,110,ERASER 2,200,PEN 0,220,BLACKBOARD 1,300,CHALK ====
Thanks so much for your patience.$VAR1 = { 'SET1' => [ [ '0','100','BOOK'], [ '1','150','PENCIL'], ], 'SET2' => [ [ '2','110','ERASER'], [ '2','200','PEN'], [ '0','220','BLACKBOARD'], [ '1','300','CHALK'], ] };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Fail to update an array in HoAoA
by tphyahoo (Vicar) on Jul 20, 2005 at 08:25 UTC | |
by Anonymous Monk on Jul 20, 2005 at 08:57 UTC | |
|
Re: Fail to update an array in HoAoA
by Tanalis (Curate) on Jul 20, 2005 at 07:52 UTC | |
|
Re: Fail to update an array in HoAoA
by Fang (Pilgrim) on Jul 20, 2005 at 07:43 UTC | |
|
Re: Fail to update an array in HoAoA
by tphyahoo (Vicar) on Jul 20, 2005 at 08:10 UTC |