in reply to Newbie Trying to Read and Reformat File
Then to print, loop through @records, loop through the keys or values of each %record, and print them with a join. Make sense?my @records; my @fields = qw( Company Title Phone Address Contact ); # read in a record at a time { my %record; @record{@fields} = ('') x @fields; foreach my $element ($line) { my ($field, $value) = split(/:\s*/, $element); $record{$field} = $value; } push @records, \%record; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Newbie Trying to Read and Reformat File
by faure (Sexton) on Aug 06, 2001 at 07:01 UTC | |
|
Re: Re: Newbie Trying to Read and Reformat File
by tbfive (Initiate) on Aug 05, 2001 at 23:26 UTC |