in reply to Re: Re: getting the right stuff
in thread getting the right stuff
That means the 0th element is 'name', and the 3rd element is 'phone'. In code terms:my @records; @records = qw( name ID email phone );
print "$records[0]\t$records[3]\n";
produces name phone. Does that help?
If you find accessing data by name instead of by index is easier, you can assign to a hash:
You can then loop through records, printing just the elements you want:while (<DATA>) { chomp; my ($key, $value) = split; $value =~ tr/"//d; my %record; $record{$key} = $value; push @records, \%record; }
Is that more clear?foreach my $rec (@records) { print "ID: $rec->{ID}\n"; print "Name: $rec->{name}\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: getting the right stuff
by malaga (Pilgrim) on Feb 06, 2001 at 22:22 UTC |