in reply to Re: Re: getting the right stuff
in thread getting the right stuff

@records is just an ordered list. If you assigned to it directly, it would look something like:
my @records; @records = qw( name ID email phone );
That means the 0th element is 'name', and the 3rd element is 'phone'. In code terms:

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:

while (<DATA>) { chomp; my ($key, $value) = split; $value =~ tr/"//d; my %record; $record{$key} = $value; push @records, \%record; }
You can then loop through records, printing just the elements you want:
foreach my $rec (@records) { print "ID: $rec->{ID}\n"; print "Name: $rec->{name}\n"; }
Is that more clear?

Replies are listed 'Best First'.
Re: Re: Re: Re: getting the right stuff
by malaga (Pilgrim) on Feb 06, 2001 at 22:22 UTC
    the thing is i don't want to print ID, Name, etc. I want to print only the values. Gladys, Black, etc. i want to be able to control that. i want to be able to print it in a specific order.